Skip to content

Commit

Permalink
(#72) CodeGen, Parser: add tests for fixed arrays inside of structs
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jul 31, 2022
1 parent 3475437 commit 930c193
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cesium.CodeGen.Tests/CodeGenTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ public Task ArrayDeclaration() => DoTest(@"int main()
[Fact]
public Task BasicTypeDef() => DoTest(@"typedef int foo;
int main(void) { foo x; return 0; }");

[Fact]
public Task StructWithArray() => DoTest(@"typedef struct {
int x[4];
} foo;");
}
5 changes: 5 additions & 0 deletions Cesium.Parser.Tests/ParserTests/DeclarationParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ public Task CliImport() => DoDeclarationParserTest(@"__cli_import(""System.Runti

[Fact]
public Task ComplexFunctionPointerTypeDef() => DoDeclarationParserTest("typedef void (*foo)(uint64_t, const uint32_t*);");

[Fact]
public Task StructWithArray() => DoDeclarationParserTest(@"typedef struct {
int x[4];
} foo;");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$type": "Cesium.Ast.Declaration, Cesium.Ast",
"Specifiers": [
{
"$type": "Cesium.Ast.StorageClassSpecifier, Cesium.Ast",
"Name": "typedef"
},
{
"$type": "Cesium.Ast.StructOrUnionSpecifier, Cesium.Ast",
"TypeKind": "Struct",
"Identifier": null,
"StructDeclarations": [
{
"$type": "Cesium.Ast.StructDeclaration, Cesium.Ast",
"SpecifiersQualifiers": [
{
"$type": "Cesium.Ast.SimpleTypeSpecifier, Cesium.Ast",
"TypeName": "int"
}
],
"Declarators": [
{
"$type": "Cesium.Ast.StructDeclarator, Cesium.Ast",
"Declarator": {
"$type": "Cesium.Ast.Declarator, Cesium.Ast",
"Pointer": null,
"DirectDeclarator": {
"$type": "Cesium.Ast.ArrayDirectDeclarator, Cesium.Ast",
"Base": {
"$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast",
"Identifier": "x",
"Base": null
},
"TypeQualifiers": null,
"Size": {
"$type": "Cesium.Ast.ConstantExpression, Cesium.Ast",
"Constant": {
"Kind": "IntLiteral",
"Text": "4"
}
}
}
}
}
]
}
]
}
],
"InitDeclarators": [
{
"$type": "Cesium.Ast.InitDeclarator, Cesium.Ast",
"Declarator": {
"$type": "Cesium.Ast.Declarator, Cesium.Ast",
"Pointer": null,
"DirectDeclarator": {
"$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast",
"Identifier": "foo",
"Base": null
}
},
"Initializer": null
}
]
}

0 comments on commit 930c193

Please sign in to comment.