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

Method testArraySpansClickable

tests/test_compose.cpp:779–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777 }
778
779 void testArraySpansClickable() {
780 // Element type and count spans must cover the correct text regions
781 NodeTree tree;
782 tree.baseAddress = 0;
783
784 Node root;
785 root.kind = NodeKind::Struct;
786 root.name = "Root";
787 root.parentId = 0;
788 int ri = tree.addNode(root);
789 uint64_t rootId = tree.nodes[ri].id;
790
791 Node arr;
792 arr.kind = NodeKind::Array;
793 arr.name = "numbers";
794 arr.parentId = rootId;
795 arr.offset = 0;
796 arr.elementKind = NodeKind::UInt32;
797 arr.arrayLen = 5;
798 tree.addNode(arr);
799
800 NullProvider prov;
801 ComposeResult result = compose(tree, prov);
802
803 int headerLine = -1;
804 for (int i = 0; i < result.meta.size(); i++) {
805 if (result.meta[i].isArrayHeader) { headerLine = i; break; }
806 }
807 QVERIFY(headerLine >= 0);
808
809 QStringList lines = result.text.split('\n');
810 QString lineText = lines[headerLine];
811 const LineMeta& lm = result.meta[headerLine];
812
813 // Element type span must be valid and cover "uint32_t"
814 ColumnSpan typeSpan = arrayElemTypeSpanFor(lm, lineText);
815 QVERIFY2(typeSpan.valid, "arrayElemTypeSpanFor must return a valid span");
816 QVERIFY(typeSpan.start < typeSpan.end);
817 QString typeText = lineText.mid(typeSpan.start, typeSpan.end - typeSpan.start);
818 QVERIFY2(typeText.contains("uint32_t"),
819 qPrintable("Type span should cover 'uint32_t', got: '" + typeText + "'"));
820
821 // Element count span must be valid and cover "5"
822 ColumnSpan countSpan = arrayElemCountSpanFor(lm, lineText);
823 QVERIFY2(countSpan.valid, "arrayElemCountSpanFor must return a valid span");
824 QVERIFY(countSpan.start < countSpan.end);
825 QString countText = lineText.mid(countSpan.start, countSpan.end - countSpan.start);
826 QCOMPARE(countText, QString("5"));
827 }
828
829 void testArrayWithStructChildren() {
830 // Array with struct children renders separators and child fields

Callers

nothing calls this directly

Calls 5

composeFunction · 0.85
arrayElemTypeSpanForFunction · 0.85
arrayElemCountSpanForFunction · 0.85
addNodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected