nswrap/ast/parm_var_decl_test.go

156 lines
4.3 KiB
Go
Raw Normal View History

2019-04-09 11:52:21 -04:00
package ast
import (
"testing"
)
func TestParmVarDecl(t *testing.T) {
2019-06-04 00:14:04 -04:00
nodes := map[string]testNode{
`0x7f973380f000 <col:14> col:17 'int'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f973380f000,
Pos: NewPositionFromString("col:14"),
Position2: "col:17",
Type: "int",
Name: "",
Type2: "",
IsUsed: false,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f973380f000,
NewPositionFromString("col:14"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f973380f070 <col:19, col:30> col:31 'const char *'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f973380f070,
Pos: NewPositionFromString("col:19, col:30"),
Position2: "col:31",
Type: "const char *",
Name: "",
Type2: "",
IsUsed: false,
IsReferenced: false,
ChildNodes: []Node{},
},
0x7f973380f070,
NewPositionFromString("col:19, col:30"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f9733816e50 <col:13, col:37> col:37 __filename 'const char *__restrict'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f9733816e50,
Pos: NewPositionFromString("col:13, col:37"),
Position2: "col:37",
Type: "const char *__restrict",
Name: "__filename",
Type2: "",
IsUsed: false,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f9733816e50,
NewPositionFromString("col:13, col:37"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f9733817418 <<invalid sloc>> <invalid sloc> 'FILE *'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f9733817418,
Pos: NewPositionFromString("<invalid sloc>"),
Position2: "<invalid sloc>",
Type: "FILE *",
Name: "",
Type2: "",
IsUsed: false,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f9733817418,
NewPositionFromString("<invalid sloc>"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f9733817c30 <col:40, col:47> col:47 __size 'size_t':'unsigned long'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f9733817c30,
Pos: NewPositionFromString("col:40, col:47"),
Position2: "col:47",
Type: "size_t",
Name: "__size",
2019-05-31 10:21:04 -04:00
Type2: "",
2019-04-09 11:52:21 -04:00
IsUsed: false,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f9733817c30,
NewPositionFromString("col:40, col:47"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f973382fa10 <line:476:18, col:25> col:34 'int (* _Nullable)(void *, char *, int)':'int (*)(void *, char *, int)'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f973382fa10,
Pos: NewPositionFromString("line:476:18, col:25"),
Position2: "col:34",
Type: "int (* _Nullable)(void *, char *, int)",
Name: "",
2019-05-31 10:21:04 -04:00
Type2: "",
2019-04-09 11:52:21 -04:00
IsUsed: false,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f973382fa10,
NewPositionFromString("line:476:18, col:25"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f97338355b8 <col:10, col:14> col:14 used argc 'int'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f97338355b8,
Pos: NewPositionFromString("col:10, col:14"),
Position2: "col:14",
Type: "int",
Name: "argc",
Type2: "",
IsUsed: true,
IsReferenced: false,
IsRegister: false,
ChildNodes: []Node{},
},
0x7f97338355b8,
NewPositionFromString("col:10, col:14"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x1d82850 <col:11, col:22> col:16 referenced foo 'char *':'char *'`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x1d82850,
Pos: NewPositionFromString("col:11, col:22"),
Position2: "col:16",
Type: "char *",
Name: "foo",
2019-05-31 10:21:04 -04:00
Type2: "",
2019-04-09 11:52:21 -04:00
IsUsed: false,
IsReferenced: true,
IsRegister: false,
ChildNodes: []Node{},
},
0x1d82850,
NewPositionFromString("col:11, col:22"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7f95f30ed9d0 <col:23, col:51> col:51 used eptr 'const char *' register`: testNode{&ParmVarDecl{
2019-04-09 11:52:21 -04:00
Addr: 0x7f95f30ed9d0,
Pos: NewPositionFromString("col:23, col:51"),
Position2: "col:51",
Type: "const char *",
Name: "eptr",
Type2: "",
IsUsed: true,
IsReferenced: false,
IsRegister: true,
ChildNodes: []Node{},
},
0x7f95f30ed9d0,
NewPositionFromString("col:23, col:51"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
2019-04-09 11:52:21 -04:00
}
runNodeTests(t, nodes)
}