── Test: setNodeValue writes bytes to provider ──
| 96 | |
| 97 | // ── Test: setNodeValue writes bytes to provider ── |
| 98 | void testSetNodeValueWritesData() { |
| 99 | // Find field_u32 (index 1, child of root at index 0) |
| 100 | int idx = -1; |
| 101 | for (int i = 0; i < m_doc->tree.nodes.size(); i++) { |
| 102 | if (m_doc->tree.nodes[i].name == "field_u32") { idx = i; break; } |
| 103 | } |
| 104 | QVERIFY(idx >= 0); |
| 105 | |
| 106 | // Verify original value in provider |
| 107 | uint64_t addr = m_doc->tree.computeOffset(idx); |
| 108 | QByteArray origBytes = m_doc->provider->readBytes(addr, 4); |
| 109 | uint32_t origVal; |
| 110 | memcpy(&origVal, origBytes.data(), 4); |
| 111 | QCOMPARE(origVal, (uint32_t)0xDEADBEEF); |
| 112 | |
| 113 | // Write new value "42" (decimal) |
| 114 | m_ctrl->setNodeValue(idx, 0, "42"); |
| 115 | QApplication::processEvents(); |
| 116 | |
| 117 | // Read back: should be 42 in little-endian |
| 118 | QByteArray newBytes = m_doc->provider->readBytes(addr, 4); |
| 119 | uint32_t newVal; |
| 120 | memcpy(&newVal, newBytes.data(), 4); |
| 121 | QCOMPARE(newVal, (uint32_t)42); |
| 122 | } |
| 123 | |
| 124 | // ── Test: setNodeValue undo/redo restores data ── |
| 125 | void testSetNodeValueUndoRedo() { |
nothing calls this directly
no test coverage detected