diff --git a/cmd/genbindings/transformchildclasses_test.go b/cmd/genbindings/transformchildclasses_test.go new file mode 100644 index 00000000..456b5fac --- /dev/null +++ b/cmd/genbindings/transformchildclasses_test.go @@ -0,0 +1,49 @@ +package main + +import ( + "testing" +) + +func TestChildClassesExtract(t *testing.T) { + + src := CppParsedHeader{ + Classes: []CppClass{ + + CppClass{ + ClassName: "Parent", + + ChildClassdefs: []CppClass{ + + CppClass{ + ClassName: "Parent::Child", + + ChildClassdefs: []CppClass{ + + CppClass{ + ClassName: "Parent::Child::Grandchild", + }, + }, + }, + }, + }, + }, + } + + astTransformChildClasses(&src) + if len(src.Classes) != 3 { + t.Fatal("expected 3 classes") + } + + if src.Classes[0].ClassName != "Parent" { + t.Fatal("expected parent class name") + } + + if src.Classes[1].ClassName != "Parent::Child::Grandchild" { + t.Fatal("expected grandchild class name") + } + + if src.Classes[2].ClassName != "Parent::Child" { + t.Fatal("expected child class name") + } + +}