MCPcopy Create free account
hub / github.com/IChooseYou/Reclass / testDeeplyNested

Method testDeeplyNested

tests/test_generator.cpp:611–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609 // ── Deeply nested structs ──
610
611 void testDeeplyNested() {
612 rcx::NodeTree tree;
613
614 // A > B > C, each containing one field
615 rcx::Node a;
616 a.kind = rcx::NodeKind::Struct;
617 a.name = "A";
618 a.structTypeName = "TypeA";
619 a.parentId = 0;
620 int ai = tree.addNode(a);
621 uint64_t aId = tree.nodes[ai].id;
622
623 rcx::Node b;
624 b.kind = rcx::NodeKind::Struct;
625 b.name = "b";
626 b.structTypeName = "TypeB";
627 b.parentId = aId;
628 b.offset = 0;
629 int bi = tree.addNode(b);
630 uint64_t bId = tree.nodes[bi].id;
631
632 rcx::Node c;
633 c.kind = rcx::NodeKind::Struct;
634 c.name = "c";
635 c.structTypeName = "TypeC";
636 c.parentId = bId;
637 c.offset = 0;
638 int ci = tree.addNode(c);
639 uint64_t cId = tree.nodes[ci].id;
640
641 rcx::Node leaf;
642 leaf.kind = rcx::NodeKind::UInt8;
643 leaf.name = "val";
644 leaf.parentId = cId;
645 leaf.offset = 0;
646 tree.addNode(leaf);
647
648 QString result = rcx::renderCpp(tree, aId);
649
650 // TypeC defined first, then TypeB, then TypeA
651 int cPos = result.indexOf("struct TypeC {");
652 int bPos = result.indexOf("struct TypeB {");
653 int aPos = result.indexOf("struct TypeA {");
654 QVERIFY(cPos >= 0);
655 QVERIFY(bPos >= 0);
656 QVERIFY(aPos >= 0);
657 QVERIFY(cPos < bPos);
658 QVERIFY(bPos < aPos);
659
660 // TypeA contains TypeB, TypeB contains TypeC
661 QVERIFY(result.contains("TypeB b;"));
662 QVERIFY(result.contains("TypeC c;"));
663 QVERIFY(result.contains("uint8_t val;"));
664 }
665};
666
667QTEST_MAIN(TestGenerator)

Callers

nothing calls this directly

Calls 2

renderCppFunction · 0.85
addNodeMethod · 0.45

Tested by

no test coverage detected