diff options
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer')
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index d0bc237a5d..187b73eeec 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -294,8 +294,8 @@ void tst_QSharedPointer::basics() QVERIFY(! (ptr == otherData)); QVERIFY(! (otherData == ptr)); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create another object: @@ -307,8 +307,8 @@ void tst_QSharedPointer::basics() // otherData is deleted here } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a copy: @@ -325,8 +325,8 @@ void tst_QSharedPointer::basics() QCOMPARE(copy.get(), aData); QVERIFY(copy == aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a weak reference: @@ -358,8 +358,8 @@ void tst_QSharedPointer::basics() QCOMPARE(strong.data(), aData); QCOMPARE(strong.get(), aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); // aData is deleted here } @@ -843,15 +843,15 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<DerivedData> derivedptr = qWeakPointerCast<DerivedData>(baseptr); QVERIFY(baseptr == derivedptr); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -859,16 +859,16 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.staticCast<DerivedData>(); QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } class OtherObject: public QObject @@ -1297,8 +1297,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1307,8 +1307,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>(); @@ -1316,8 +1316,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastDifferentPointers() @@ -1332,8 +1332,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1342,8 +1342,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>(); @@ -1351,8 +1351,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { Stuffing *nakedptr = dynamic_cast<Stuffing *>(baseptr.data()); @@ -1377,8 +1377,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1387,8 +1387,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>(); @@ -1396,8 +1396,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailure() @@ -1409,15 +1409,15 @@ void tst_QSharedPointer::dynamicCastFailure() QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(baseptr); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>(); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailureNoLeak() @@ -1786,8 +1786,8 @@ void tst_QSharedPointer::creating() QCOMPARE(Data::destructorCounter, 1); // valgrind will complain here if something happened to the pointer - QVERIFY(d->weakref.load() == 1); - QVERIFY(d->strongref.load() == 0); + QVERIFY(d->weakref.loadRelaxed() == 1); + QVERIFY(d->strongref.loadRelaxed() == 0); } safetyCheck(); @@ -2022,7 +2022,7 @@ void tst_QSharedPointer::threadStressTest() for (int r = 0; r < 5; ++r) { QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0); QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter)); - counter.store(0); + counter.storeRelaxed(0); // set the pointers for (int i = 0; i < strongThreadCount; ++i) { @@ -2056,8 +2056,8 @@ void tst_QSharedPointer::threadStressTest() // verify that the count is the right range int minValue = strongThreadCount; int maxValue = strongThreadCount + weakThreadCount; - QVERIFY(counter.load() >= minValue); - QVERIFY(counter.load() <= maxValue); + QVERIFY(counter.loadRelaxed() >= minValue); + QVERIFY(counter.loadRelaxed() <= maxValue); } } |