| 1716 | } |
| 1717 | |
| 1718 | void testPointerRefIdToDeletedStruct() { |
| 1719 | // If refId points to a non-existent node, degrade to void* |
| 1720 | NodeTree tree; |
| 1721 | tree.baseAddress = 0; |
| 1722 | |
| 1723 | Node root; |
| 1724 | root.kind = NodeKind::Struct; |
| 1725 | root.name = "Root"; |
| 1726 | root.parentId = 0; |
| 1727 | int ri = tree.addNode(root); |
| 1728 | uint64_t rootId = tree.nodes[ri].id; |
| 1729 | |
| 1730 | Node ptr; |
| 1731 | ptr.kind = NodeKind::Pointer64; |
| 1732 | ptr.name = "dangling"; |
| 1733 | ptr.parentId = rootId; |
| 1734 | ptr.offset = 0; |
| 1735 | ptr.refId = 99999; // non-existent ID |
| 1736 | tree.addNode(ptr); |
| 1737 | |
| 1738 | NullProvider prov; |
| 1739 | ComposeResult result = compose(tree, prov); |
| 1740 | |
| 1741 | // Should not crash, and degrade to void |
| 1742 | QStringList lines = result.text.split('\n'); |
| 1743 | bool foundVoid = false; |
| 1744 | for (const QString& l : lines) { |
| 1745 | if (l.contains("void*")) { foundVoid = true; break; } |
| 1746 | } |
| 1747 | QVERIFY2(foundVoid, "Dangling refId should degrade to void*"); |
| 1748 | } |
| 1749 | |
| 1750 | void testPointerCollapsedNoExpansion() { |
| 1751 | // Collapsed pointer with valid non-null target must NOT expand |