@@ -1447,9 +1447,24 @@ const (
14471447}
14481448
14491449func TestIdentRefer (t * testing.T ) {
1450- t .Run ("undef ident ref" , func (t * testing.T ) {
1451- pkg := createTestPkg (t , & convert.PackageConfig {})
1450+ pkg := createTestPkg (t , & convert.PackageConfig {})
1451+ pkg .SetCurFile ("/path/to/stdio.h" , "stdio.h" , true , false , true )
1452+ pkg .NewTypedefDecl (& ast.TypedefDecl {
1453+ DeclBase : ast.DeclBase {
1454+ Loc : & ast.Location {File : "/path/to/stdio.h" },
1455+ },
1456+ Name : & ast.Ident {Name : "undefType" },
1457+ Type : & ast.BuiltinType {
1458+ Kind : ast .Char ,
1459+ Flags : ast .Signed ,
1460+ },
1461+ })
1462+ pkg .SetCurFile ("/path/to/notsys.h" , "notsys.h" , true , true , false )
1463+ t .Run ("undef sys ident ref" , func (t * testing.T ) {
14521464 err := pkg .NewTypeDecl (& ast.TypeDecl {
1465+ DeclBase : ast.DeclBase {
1466+ Loc : & ast.Location {File : "/path/to/notsys.h" },
1467+ },
14531468 Name : & ast.Ident {Name : "Foo" },
14541469 Type : & ast.RecordType {
14551470 Tag : ast .Struct ,
@@ -1468,9 +1483,8 @@ func TestIdentRefer(t *testing.T) {
14681483 compareError (t , err , "undefType not found" )
14691484 })
14701485 t .Run ("undef tag ident ref" , func (t * testing.T ) {
1471- pkg := createTestPkg (t , & convert.PackageConfig {})
14721486 err := pkg .NewTypeDecl (& ast.TypeDecl {
1473- Name : & ast.Ident {Name : "Foo " },
1487+ Name : & ast.Ident {Name : "Bar " },
14741488 Type : & ast.RecordType {
14751489 Tag : ast .Struct ,
14761490 Fields : & ast.FieldList {
0 commit comments