MCPcopy Create free account
hub / github.com/KDE/kdevelop / testMoveAssignment

Method testMoveAssignment

kdevplatform/serialization/tests/test_indexedstring.cpp:81–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void 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
109void TestIndexedString::testSwap()
110{

Callers

nothing calls this directly

Calls 2

strMethod · 0.80
~IndexedStringMethod · 0.80

Tested by

no test coverage detected