| 549 | } |
| 550 | |
| 551 | void testNormalizePreferDescendants() { |
| 552 | using namespace rcx; |
| 553 | NodeTree tree; |
| 554 | Node root; root.kind = NodeKind::Struct; root.name = "R"; root.parentId = 0; |
| 555 | int ri = tree.addNode(root); |
| 556 | uint64_t rootId = tree.nodes[ri].id; |
| 557 | |
| 558 | Node a; a.kind = NodeKind::UInt32; a.name = "a"; a.parentId = rootId; |
| 559 | int ai = tree.addNode(a); |
| 560 | uint64_t aId = tree.nodes[ai].id; |
| 561 | |
| 562 | Node b; b.kind = NodeKind::UInt32; b.name = "b"; b.parentId = rootId; b.offset = 4; |
| 563 | int bi = tree.addNode(b); |
| 564 | uint64_t bId = tree.nodes[bi].id; |
| 565 | |
| 566 | // Select root + a + b: root dropped (has selected descendants) |
| 567 | QSet<uint64_t> sel = {rootId, aId, bId}; |
| 568 | QSet<uint64_t> norm = tree.normalizePreferDescendants(sel); |
| 569 | QCOMPARE(norm.size(), 2); |
| 570 | QVERIFY(norm.contains(aId)); |
| 571 | QVERIFY(norm.contains(bId)); |
| 572 | QVERIFY(!norm.contains(rootId)); |
| 573 | |
| 574 | // Select root + a: root dropped, a kept |
| 575 | sel = {rootId, aId}; |
| 576 | norm = tree.normalizePreferDescendants(sel); |
| 577 | QCOMPARE(norm.size(), 1); |
| 578 | QVERIFY(norm.contains(aId)); |
| 579 | |
| 580 | // Select only root: nothing dropped (no descendants selected) |
| 581 | sel = {rootId}; |
| 582 | norm = tree.normalizePreferDescendants(sel); |
| 583 | QCOMPARE(norm.size(), 1); |
| 584 | QVERIFY(norm.contains(rootId)); |
| 585 | } |
| 586 | }; |
| 587 | |
| 588 | QTEST_MAIN(TestCore) |
nothing calls this directly
no test coverage detected