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

Function buildSmallTree

tests/test_controller.cpp:13–41  ·  view source on GitHub ↗

Small tree: one root struct with a few typed fields at known offsets. Keeps tests fast and deterministic (no giant PEB tree).

Source from the content-addressed store, hash-verified

11// Small tree: one root struct with a few typed fields at known offsets.
12// Keeps tests fast and deterministic (no giant PEB tree).
13static void buildSmallTree(NodeTree& tree) {
14 tree.baseAddress = 0x1000;
15
16 Node root;
17 root.kind = NodeKind::Struct;
18 root.structTypeName = "TestStruct";
19 root.name = "root";
20 root.parentId = 0;
21 root.offset = 0;
22 int ri = tree.addNode(root);
23 uint64_t rootId = tree.nodes[ri].id;
24
25 auto field = [&](int off, NodeKind k, const char* name) {
26 Node n;
27 n.kind = k;
28 n.name = name;
29 n.parentId = rootId;
30 n.offset = off;
31 tree.addNode(n);
32 };
33
34 field(0, NodeKind::UInt32, "field_u32"); // 4 bytes
35 field(4, NodeKind::Float, "field_float"); // 4 bytes
36 field(8, NodeKind::UInt8, "field_u8"); // 1 byte
37 field(9, NodeKind::Padding, "pad0"); // 3 bytes padding
38 // Set padding arrayLen = 3 for 3-byte padding
39 tree.nodes.last().arrayLen = 3;
40 field(12, NodeKind::Hex32, "field_hex"); // 4 bytes
41}
42
43// 64-byte buffer with recognizable pattern
44static QByteArray makeSmallBuffer() {

Callers 1

initMethod · 0.85

Calls 1

addNodeMethod · 0.45

Tested by

no test coverage detected