llcppsigfetch:basic enum
This commit is contained in:
@@ -11,6 +11,7 @@ func main() {
|
||||
TestComment()
|
||||
TestStructDecl()
|
||||
TestClassDecl()
|
||||
TestEnumDecl()
|
||||
}
|
||||
|
||||
func TestFuncDecl() {
|
||||
@@ -194,3 +195,40 @@ func TestClassDecl() {
|
||||
converter.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnumDecl() {
|
||||
testCases := []string{
|
||||
`enum Foo {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b = 2,
|
||||
c = 4,
|
||||
};`,
|
||||
`enum Foo {
|
||||
a = 1,
|
||||
b,
|
||||
c,
|
||||
};`,
|
||||
}
|
||||
|
||||
for i, content := range testCases {
|
||||
converter, err := parse.NewConverter(content, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, err = converter.Convert()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
json := converter.MarshalASTFiles()
|
||||
c.Printf(c.Str("TestEnumDecl Case %d:\n%s\n\n"), c.Int(i+1), json.Print())
|
||||
|
||||
converter.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1296,6 +1296,144 @@ TestClassDecl Case 2:
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 1:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "0"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 2:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "4"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
TestEnumDecl Case 3:
|
||||
{
|
||||
"temp.h": {
|
||||
"path": "temp.h",
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "Foo"
|
||||
},
|
||||
"Items": [{
|
||||
"Name": {
|
||||
"Name": "a"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "1"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "b"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "2"
|
||||
}
|
||||
}, {
|
||||
"Name": {
|
||||
"Name": "c"
|
||||
},
|
||||
"Value": {
|
||||
"Kind": 0,
|
||||
"Value": "3"
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user