genbindings/test: add test cases for child class expansion

This commit is contained in:
mappu 2024-08-28 18:00:07 +12:00
parent 4451a592ab
commit cde78306c2

View File

@ -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")
}
}