| 959 | } |
| 960 | |
| 961 | void testArrayCountRecompose() { |
| 962 | // After changing arrayLen and recomposing, the text shows the new count |
| 963 | NodeTree tree; |
| 964 | tree.baseAddress = 0; |
| 965 | |
| 966 | Node root; |
| 967 | root.kind = NodeKind::Struct; |
| 968 | root.name = "Root"; |
| 969 | root.parentId = 0; |
| 970 | int ri = tree.addNode(root); |
| 971 | uint64_t rootId = tree.nodes[ri].id; |
| 972 | |
| 973 | Node arr; |
| 974 | arr.kind = NodeKind::Array; |
| 975 | arr.name = "buf"; |
| 976 | arr.parentId = rootId; |
| 977 | arr.offset = 0; |
| 978 | arr.elementKind = NodeKind::UInt8; |
| 979 | arr.arrayLen = 10; |
| 980 | int ai = tree.addNode(arr); |
| 981 | |
| 982 | NullProvider prov; |
| 983 | |
| 984 | // First compose: should show [10] |
| 985 | ComposeResult r1 = compose(tree, prov); |
| 986 | QStringList lines1 = r1.text.split('\n'); |
| 987 | bool found10 = false; |
| 988 | for (const QString& l : lines1) { |
| 989 | if (l.contains("[10]")) { found10 = true; break; } |
| 990 | } |
| 991 | QVERIFY2(found10, "First compose should show [10]"); |
| 992 | |
| 993 | // Change count and recompose |
| 994 | tree.nodes[ai].arrayLen = 42; |
| 995 | ComposeResult r2 = compose(tree, prov); |
| 996 | QStringList lines2 = r2.text.split('\n'); |
| 997 | bool found42 = false; |
| 998 | bool still10Header = false; |
| 999 | for (int i = 0; i < r2.meta.size(); i++) { |
| 1000 | if (r2.meta[i].isArrayHeader && lines2[i].contains("uint8_t[42]")) found42 = true; |
| 1001 | if (r2.meta[i].isArrayHeader && lines2[i].contains("uint8_t[10]")) still10Header = true; |
| 1002 | } |
| 1003 | QVERIFY2(found42, "Recomposed header should show uint8_t[42]"); |
| 1004 | QVERIFY2(!still10Header, "Recomposed header should NOT still show uint8_t[10]"); |
| 1005 | |
| 1006 | // Spans must still work after recompose |
| 1007 | int headerLine = -1; |
| 1008 | for (int i = 0; i < r2.meta.size(); i++) { |
| 1009 | if (r2.meta[i].isArrayHeader) { headerLine = i; break; } |
| 1010 | } |
| 1011 | QVERIFY(headerLine >= 0); |
| 1012 | ColumnSpan countSpan = arrayElemCountSpanFor(r2.meta[headerLine], lines2[headerLine]); |
| 1013 | QVERIFY2(countSpan.valid, "Count span must be valid after recompose"); |
| 1014 | QString countText = lines2[headerLine].mid(countSpan.start, countSpan.end - countSpan.start); |
| 1015 | QCOMPARE(countText, QString("42")); |
| 1016 | } |
| 1017 | |
| 1018 | void testPrimitiveArrayElements() { |
nothing calls this directly
no test coverage detected