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

Method testPointerWidthComputation

tests/test_compose.cpp:1812–1861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1810 }
1811
1812 void testPointerWidthComputation() {
1813 // Type column must be wide enough for "LongStructName*"
1814 NodeTree tree;
1815 tree.baseAddress = 0;
1816
1817 Node root;
1818 root.kind = NodeKind::Struct;
1819 root.name = "Root";
1820 root.parentId = 0;
1821 int ri = tree.addNode(root);
1822 uint64_t rootId = tree.nodes[ri].id;
1823
1824 Node target;
1825 target.kind = NodeKind::Struct;
1826 target.name = "VeryLongStructNameForTesting";
1827 target.structTypeName = "VeryLongStructNameForTesting";
1828 target.parentId = 0;
1829 target.offset = 200;
1830 int ti = tree.addNode(target);
1831 uint64_t targetId = tree.nodes[ti].id;
1832
1833 Node ptr;
1834 ptr.kind = NodeKind::Pointer64;
1835 ptr.name = "lptr";
1836 ptr.parentId = rootId;
1837 ptr.offset = 0;
1838 ptr.refId = targetId;
1839 ptr.collapsed = true;
1840 tree.addNode(ptr);
1841
1842 NullProvider prov;
1843 ComposeResult result = compose(tree, prov);
1844
1845 // The text must contain the FULL target name, not truncated
1846 QStringList lines = result.text.split('\n');
1847 bool foundFull = false;
1848 for (const QString& l : lines) {
1849 if (l.contains("VeryLongStructNameForTesting*")) {
1850 foundFull = true;
1851 break;
1852 }
1853 }
1854 QVERIFY2(foundFull,
1855 "Type column should be wide enough for long pointer target names");
1856
1857 // Layout type width should accommodate the long name
1858 // "VeryLongStructNameForTesting*" = 29 chars
1859 QVERIFY2(result.layout.typeW >= 29,
1860 qPrintable(QString("typeW=%1, should be >= 29").arg(result.layout.typeW)));
1861 }
1862
1863 // ═════════════════════════════════════════════════════════════
1864 // Class keyword + alignment tests

Callers

nothing calls this directly

Calls 2

composeFunction · 0.85
addNodeMethod · 0.45

Tested by

no test coverage detected