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

Method testPointerVoidSpans

tests/test_compose.cpp:1417–1462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1415 }
1416
1417 void testPointerVoidSpans() {
1418 // void* pointer should have valid target span but no kind span
1419 NodeTree tree;
1420 tree.baseAddress = 0;
1421
1422 Node root;
1423 root.kind = NodeKind::Struct;
1424 root.name = "Root";
1425 root.parentId = 0;
1426 int ri = tree.addNode(root);
1427 uint64_t rootId = tree.nodes[ri].id;
1428
1429 Node ptr;
1430 ptr.kind = NodeKind::Pointer64;
1431 ptr.name = "vptr";
1432 ptr.parentId = rootId;
1433 ptr.offset = 0;
1434 tree.addNode(ptr);
1435
1436 NullProvider prov;
1437 ComposeResult result = compose(tree, prov);
1438
1439 int ptrLine = -1;
1440 for (int i = 0; i < result.meta.size(); i++) {
1441 if (result.meta[i].nodeKind == NodeKind::Pointer64 &&
1442 result.meta[i].lineKind == LineKind::Field) {
1443 ptrLine = i;
1444 break;
1445 }
1446 }
1447 QVERIFY(ptrLine >= 0);
1448
1449 QStringList lines = result.text.split('\n');
1450 QString lineText = lines[ptrLine];
1451 const LineMeta& lm = result.meta[ptrLine];
1452
1453 // Kind span: no longer applicable in "Type*" format
1454 ColumnSpan kindSpan = pointerKindSpanFor(lm, lineText);
1455 QVERIFY2(!kindSpan.valid, "Kind span should be invalid in Type* format");
1456
1457 // Target span: "void" (before the '*')
1458 ColumnSpan targetSpan = pointerTargetSpanFor(lm, lineText);
1459 QVERIFY2(targetSpan.valid, "void* pointer should have valid target span");
1460 QString targetText = lineText.mid(targetSpan.start, targetSpan.end - targetSpan.start).trimmed();
1461 QCOMPARE(targetText, QString("void"));
1462 }
1463
1464 void testPointerToPointerChain() {
1465 // StructB* → StructB { StructC* } → StructC { field }

Callers

nothing calls this directly

Calls 5

composeFunction · 0.85
pointerKindSpanForFunction · 0.85
pointerTargetSpanForFunction · 0.85
addNodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected