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

Method testSetNodeValueFloat

tests/test_controller.cpp:168–198  ·  view source on GitHub ↗

── Test: setNodeValue on Float field ──

Source from the content-addressed store, hash-verified

166
167 // ── Test: setNodeValue on Float field ──
168 void testSetNodeValueFloat() {
169 int idx = -1;
170 for (int i = 0; i < m_doc->tree.nodes.size(); i++) {
171 if (m_doc->tree.nodes[i].name == "field_float") { idx = i; break; }
172 }
173 QVERIFY(idx >= 0);
174 uint64_t addr = m_doc->tree.computeOffset(idx);
175
176 // Original: 3.14f
177 QByteArray orig = m_doc->provider->readBytes(addr, 4);
178 float origVal;
179 memcpy(&origVal, orig.data(), 4);
180 QVERIFY(qAbs(origVal - 3.14f) < 0.01f);
181
182 // Write "1.5"
183 m_ctrl->setNodeValue(idx, 0, "1.5");
184 QApplication::processEvents();
185
186 QByteArray after = m_doc->provider->readBytes(addr, 4);
187 float newVal;
188 memcpy(&newVal, after.data(), 4);
189 QCOMPARE(newVal, 1.5f);
190
191 // Undo
192 m_doc->undoStack.undo();
193 QApplication::processEvents();
194 QByteArray undone = m_doc->provider->readBytes(addr, 4);
195 float undoneVal;
196 memcpy(&undoneVal, undone.data(), 4);
197 QVERIFY(qAbs(undoneVal - 3.14f) < 0.01f);
198 }
199
200 // ── Test: renameNode changes name and undo restores ──
201 void testRenameNode() {

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