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

Method testPaddingGaps

tests/test_generator.cpp:74–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 // ── Padding gap detection ──
73
74 void testPaddingGaps() {
75 rcx::NodeTree tree;
76 rcx::Node root;
77 root.kind = rcx::NodeKind::Struct;
78 root.name = "GappyStruct";
79 root.structTypeName = "GappyStruct";
80 root.parentId = 0;
81 int ri = tree.addNode(root);
82 uint64_t rootId = tree.nodes[ri].id;
83
84 // Field at offset 0, size 4
85 rcx::Node f1;
86 f1.kind = rcx::NodeKind::UInt32;
87 f1.name = "a";
88 f1.parentId = rootId;
89 f1.offset = 0;
90 tree.addNode(f1);
91
92 // Field at offset 8, size 4 (gap of 4 bytes at offset 4)
93 rcx::Node f2;
94 f2.kind = rcx::NodeKind::UInt32;
95 f2.name = "b";
96 f2.parentId = rootId;
97 f2.offset = 8;
98 tree.addNode(f2);
99
100 QString result = rcx::renderCpp(tree, rootId);
101
102 // Should contain a padding field between a and b
103 QVERIFY(result.contains("uint8_t _pad"));
104 QVERIFY(result.contains("[0x4]"));
105 QVERIFY(result.contains("uint32_t a;"));
106 QVERIFY(result.contains("uint32_t b;"));
107 }
108
109 // ── Tail padding ──
110

Callers

nothing calls this directly

Calls 2

renderCppFunction · 0.85
addNodeMethod · 0.45

Tested by

no test coverage detected