minorfixes

This commit is contained in:
batallion caputa
2026-02-08 05:59:50 -07:00
parent 9293161039
commit 105ad398b6
6 changed files with 67 additions and 47 deletions

View File

@@ -58,7 +58,7 @@ private slots:
QCOMPARE(result.meta[4].lineKind, LineKind::Footer);
}
void testVec3Continuation() {
void testVec3SingleLine() {
NodeTree tree;
tree.baseAddress = 0;
@@ -79,28 +79,17 @@ private slots:
NullProvider prov;
ComposeResult result = compose(tree, prov);
// CommandRow + CommandRow2 + 3 Vec3 lines + root footer = 6
QCOMPARE(result.meta.size(), 6);
// CommandRow + CommandRow2 + 1 Vec3 line + root footer = 4
QCOMPARE(result.meta.size(), 4);
// Line 2 (first Vec3 component): not continuation, depth 1
// Line 2: single Vec3 line, not continuation, depth 1
QVERIFY(!result.meta[2].isContinuation);
QCOMPARE(result.meta[2].offsetText, QString("0"));
QCOMPARE(result.meta[2].depth, 1);
QCOMPARE(result.meta[2].nodeKind, NodeKind::Vec3);
// Lines 3-4: continuation, depth 1
QVERIFY(result.meta[3].isContinuation);
QCOMPARE(result.meta[3].offsetText, QString(" \u00B7"));
QCOMPARE(result.meta[3].depth, 1);
QVERIFY(result.meta[4].isContinuation);
QCOMPARE(result.meta[4].offsetText, QString(" \u00B7"));
QCOMPARE(result.meta[4].depth, 1);
// Continuation marker
QVERIFY(result.meta[3].markerMask & (1u << M_CONT));
QVERIFY(result.meta[4].markerMask & (1u << M_CONT));
// Line 5 is root footer
QCOMPARE(result.meta[5].lineKind, LineKind::Footer);
// Line 3 is root footer
QCOMPARE(result.meta[3].lineKind, LineKind::Footer);
}
void testPaddingMarker() {

View File

@@ -18,9 +18,9 @@ private slots:
void testLinesForKind() {
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Hex32), 1);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec2), 2);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec3), 3);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec4), 4);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec2), 1);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec3), 1);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Vec4), 1);
QCOMPARE(rcx::linesForKind(rcx::NodeKind::Mat4x4), 4);
}

View File

@@ -222,21 +222,21 @@ private slots:
}
void testReadValueBoundsCheck() {
// Vec2 subLine=2 (out of bounds) should return "?"
// Vec2 single-line: subLine=0 returns all components
QByteArray data(16, '\0');
BufferProvider prov(data);
Node n;
n.kind = NodeKind::Vec2;
n.name = "v";
QCOMPARE(fmt::readValue(n, prov, 0, 2), QString("?"));
QCOMPARE(fmt::readValue(n, prov, 0, -1), QString("?"));
QVERIFY(fmt::readValue(n, prov, 0, 0).contains(","));
// Vec3 subLine=3 (out of bounds)
// Vec3 single-line: subLine=0 returns 3 comma-separated values
n.kind = NodeKind::Vec3;
QCOMPARE(fmt::readValue(n, prov, 0, 3), QString("?"));
QCOMPARE(fmt::readValue(n, prov, 0, 0).count(','), 2);
// Vec3 subLine=2 (valid)
QVERIFY(fmt::readValue(n, prov, 0, 2) != QString("?"));
// Vec4 single-line: subLine=0 returns 4 comma-separated values
n.kind = NodeKind::Vec4;
QCOMPARE(fmt::readValue(n, prov, 0, 0).count(','), 3);
}
void testEditableValueBasic() {
@@ -252,9 +252,10 @@ private slots:
QString s = fmt::editableValue(n, prov, 0, 0);
QVERIFY(s.contains("3.14"));
// Vec2 out of bounds → "?"
// Vec2 single-line: returns comma-separated values
n.kind = NodeKind::Vec2;
QCOMPARE(fmt::editableValue(n, prov, 0, 2), QString("?"));
QString vec2 = fmt::editableValue(n, prov, 0, 0);
QVERIFY(vec2.contains(","));
}
void testParseValueEmptyString() {

View File

@@ -860,6 +860,45 @@ private slots:
QVERIFY(cpp.contains("my_float speed;"));
}
}
void testVec4SingleLineValue() {
NodeTree tree;
tree.baseAddress = 0;
Node root;
root.kind = NodeKind::Struct;
root.name = "Obj";
root.parentId = 0;
int ri = tree.addNode(root);
uint64_t rootId = tree.nodes[ri].id;
Node v;
v.kind = NodeKind::Vec4;
v.name = "position";
v.parentId = rootId;
v.offset = 0;
tree.addNode(v);
NullProvider prov;
ComposeResult result = compose(tree, prov);
// CommandRow + CommandRow2 + 1 Vec4 line + footer = 4
QCOMPARE(result.meta.size(), 4);
// The Vec4 line (index 2) is a single field line, not continuation
QCOMPARE(result.meta[2].lineKind, LineKind::Field);
QCOMPARE(result.meta[2].nodeKind, NodeKind::Vec4);
QVERIFY(!result.meta[2].isContinuation);
// Copy text (equivalent to editor's "Copy All as Text")
QString text = result.text;
// NullProvider reads 0 for all floats, so values are "0, 0, 0, 0"
QVERIFY(text.contains("0, 0, 0, 0"));
// Confirm type, name, and values all on the same line
QStringList lines = text.split('\n');
QVERIFY(lines[2].contains("Vec4"));
QVERIFY(lines[2].contains("position"));
QVERIFY(lines[2].contains("0, 0, 0, 0"));
}
};
QTEST_MAIN(TestNewFeatures)