| 79 | } |
| 80 | |
| 81 | void TestIndexedString::testMoveAssignment() |
| 82 | { |
| 83 | // Deliberately make no assumptions about the value of the moved-from object. |
| 84 | |
| 85 | const QString text = QStringLiteral("random text"); |
| 86 | IndexedString movedFrom(text); |
| 87 | QCOMPARE(movedFrom.str(), text); |
| 88 | |
| 89 | IndexedString notRefCounted; |
| 90 | notRefCounted = std::move(movedFrom); |
| 91 | QCOMPARE(notRefCounted.str(), text); |
| 92 | |
| 93 | movedFrom = std::move(notRefCounted); |
| 94 | QCOMPARE(movedFrom.str(), text); |
| 95 | |
| 96 | const QString toBeDerefed = QStringLiteral("to-be-derefed"); |
| 97 | |
| 98 | // Enable reference counting throughout refCounted's lifetime. |
| 99 | std::byte indexedStringData[sizeof(IndexedString)]; |
| 100 | const DUChainReferenceCountingEnabler rcEnabler(indexedStringData, sizeof(IndexedString)); |
| 101 | IndexedString* const refCounted = new (indexedStringData) IndexedString(toBeDerefed); |
| 102 | QCOMPARE(refCounted->str(), toBeDerefed); |
| 103 | |
| 104 | *refCounted = std::move(movedFrom); |
| 105 | QCOMPARE(refCounted->str(), text); |
| 106 | refCounted->~IndexedString(); |
| 107 | } |
| 108 | |
| 109 | void TestIndexedString::testSwap() |
| 110 | { |
nothing calls this directly
no test coverage detected