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

Method testSetNodeValueHex

tests/test_controller.cpp:327–358  ·  view source on GitHub ↗

── Test: setNodeValue with Hex32 (space-separated hex bytes) ──

Source from the content-addressed store, hash-verified

325
326 // ── Test: setNodeValue with Hex32 (space-separated hex bytes) ──
327 void testSetNodeValueHex() {
328 int idx = -1;
329 for (int i = 0; i < m_doc->tree.nodes.size(); i++) {
330 if (m_doc->tree.nodes[i].name == "field_hex") { idx = i; break; }
331 }
332 QVERIFY(idx >= 0);
333 uint64_t addr = m_doc->tree.computeOffset(idx);
334
335 // Original: 0xCAFEBABE
336 QByteArray orig = m_doc->provider->readBytes(addr, 4);
337 uint32_t origVal;
338 memcpy(&origVal, orig.data(), 4);
339 QCOMPARE(origVal, (uint32_t)0xCAFEBABE);
340
341 // Write space-separated hex bytes "AA BB CC DD"
342 m_ctrl->setNodeValue(idx, 0, "AA BB CC DD");
343 QApplication::processEvents();
344
345 QByteArray after = m_doc->provider->readBytes(addr, 4);
346 QCOMPARE((uint8_t)after[0], (uint8_t)0xAA);
347 QCOMPARE((uint8_t)after[1], (uint8_t)0xBB);
348 QCOMPARE((uint8_t)after[2], (uint8_t)0xCC);
349 QCOMPARE((uint8_t)after[3], (uint8_t)0xDD);
350
351 // Undo
352 m_doc->undoStack.undo();
353 QApplication::processEvents();
354 QByteArray undone = m_doc->provider->readBytes(addr, 4);
355 uint32_t undoneVal;
356 memcpy(&undoneVal, undone.data(), 4);
357 QCOMPARE(undoneVal, (uint32_t)0xCAFEBABE);
358 }
359
360 // ── Test: full inline edit round-trip (type in editor → commit → verify provider) ──
361 void testInlineEditRoundTrip() {

Callers

nothing calls this directly

Calls 5

computeOffsetMethod · 0.80
readBytesMethod · 0.80
setNodeValueMethod · 0.80
sizeMethod · 0.45
undoMethod · 0.45

Tested by

no test coverage detected