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

Method testArrayHeaderFormat

tests/test_compose.cpp:679–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677 // ═════════════════════════════════════════════════════════════
678
679 void testArrayHeaderFormat() {
680 // Array header must show "elemType[count]" text and proper metadata
681 NodeTree tree;
682 tree.baseAddress = 0;
683
684 Node root;
685 root.kind = NodeKind::Struct;
686 root.name = "Root";
687 root.parentId = 0;
688 int ri = tree.addNode(root);
689 uint64_t rootId = tree.nodes[ri].id;
690
691 Node arr;
692 arr.kind = NodeKind::Array;
693 arr.name = "data";
694 arr.parentId = rootId;
695 arr.offset = 0;
696 arr.elementKind = NodeKind::Int32;
697 arr.arrayLen = 10;
698 tree.addNode(arr);
699
700 NullProvider prov;
701 ComposeResult result = compose(tree, prov);
702
703 // Find the array header line
704 int headerLine = -1;
705 for (int i = 0; i < result.meta.size(); i++) {
706 if (result.meta[i].isArrayHeader) {
707 headerLine = i;
708 break;
709 }
710 }
711 QVERIFY(headerLine >= 0);
712
713 // Metadata must be correct
714 const LineMeta& lm = result.meta[headerLine];
715 QCOMPARE(lm.lineKind, LineKind::Header);
716 QVERIFY(lm.isArrayHeader);
717 QCOMPARE(lm.elementKind, NodeKind::Int32);
718 QCOMPARE(lm.arrayCount, 10);
719 QVERIFY(lm.foldHead);
720 QVERIFY(!lm.foldCollapsed);
721
722 // Text must contain "int32_t[10]" and the name
723 QStringList lines = result.text.split('\n');
724 QVERIFY(headerLine < lines.size());
725 QString text = lines[headerLine];
726 QVERIFY2(text.contains("int32_t[10]"),
727 qPrintable("Header should contain 'int32_t[10]': " + text));
728 QVERIFY2(text.contains("data"),
729 qPrintable("Header should contain 'data': " + text));
730 QVERIFY2(text.contains("{"),
731 qPrintable("Expanded header should contain '{': " + text));
732 }
733
734 void testArrayHeaderCharTypes() {
735 // UInt8 array → "uint8_t[N]", UInt16 → "uint16_t[N]"

Callers

nothing calls this directly

Calls 3

composeFunction · 0.85
addNodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected