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

Method testNodeTree_jsonRoundTrip

tests/test_core.cpp:92–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90 }
91
92 void testNodeTree_jsonRoundTrip() {
93 rcx::NodeTree tree;
94 tree.baseAddress = 0xDEAD;
95 rcx::Node root; root.kind = rcx::NodeKind::Struct; root.name = "Test";
96 root.parentId = 0; root.offset = 0;
97 int ri = tree.addNode(root);
98 uint64_t rootId = tree.nodes[ri].id;
99
100 rcx::Node child; child.kind = rcx::NodeKind::Float; child.name = "val";
101 child.parentId = rootId; child.offset = 8;
102 tree.addNode(child);
103
104 QJsonObject json = tree.toJson();
105 rcx::NodeTree tree2 = rcx::NodeTree::fromJson(json);
106
107 QCOMPARE(tree2.baseAddress, (uint64_t)0xDEAD);
108 QCOMPARE(tree2.nodes.size(), 2);
109 QCOMPARE(tree2.nodes[0].name, QString("Test"));
110 QCOMPARE(tree2.nodes[1].kind, rcx::NodeKind::Float);
111 QCOMPARE(tree2.nodes[1].offset, 8);
112 }
113
114 void testBufferProvider() {
115 QByteArray data(16, '\0');

Callers

nothing calls this directly

Calls 3

addNodeMethod · 0.45
toJsonMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected