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

Method testInsertAndRemoveNode

tests/test_controller.cpp:246–283  ·  view source on GitHub ↗

── Test: insertNode adds a node, removeNode removes it, undo restores ──

Source from the content-addressed store, hash-verified

244
245 // ── Test: insertNode adds a node, removeNode removes it, undo restores ──
246 void testInsertAndRemoveNode() {
247 int origSize = m_doc->tree.nodes.size();
248 uint64_t rootId = m_doc->tree.nodes[0].id;
249
250 // Insert a new Hex64 at offset 16
251 m_ctrl->insertNode(rootId, 16, NodeKind::Hex64, "newHex");
252 QApplication::processEvents();
253
254 QCOMPARE(m_doc->tree.nodes.size(), origSize + 1);
255
256 // Find the inserted node
257 int newIdx = -1;
258 for (int i = 0; i < m_doc->tree.nodes.size(); i++) {
259 if (m_doc->tree.nodes[i].name == "newHex") { newIdx = i; break; }
260 }
261 QVERIFY(newIdx >= 0);
262 QCOMPARE(m_doc->tree.nodes[newIdx].kind, NodeKind::Hex64);
263 QCOMPARE(m_doc->tree.nodes[newIdx].offset, 16);
264
265 // Remove it
266 m_ctrl->removeNode(newIdx);
267 QApplication::processEvents();
268
269 QCOMPARE(m_doc->tree.nodes.size(), origSize);
270
271 // Undo remove → node restored
272 m_doc->undoStack.undo();
273 QApplication::processEvents();
274
275 QCOMPARE(m_doc->tree.nodes.size(), origSize + 1);
276
277 // Find again
278 newIdx = -1;
279 for (int i = 0; i < m_doc->tree.nodes.size(); i++) {
280 if (m_doc->tree.nodes[i].name == "newHex") { newIdx = i; break; }
281 }
282 QVERIFY(newIdx >= 0);
283 }
284
285 // ── Test: Padding value edit is effectively blocked at controller level ──
286 void testPaddingValueEditIsBlocked() {

Callers

nothing calls this directly

Calls 4

insertNodeMethod · 0.80
sizeMethod · 0.45
removeNodeMethod · 0.45
undoMethod · 0.45

Tested by

no test coverage detected