Test QAtomicPointer<const T>
Commit f4b6628083
fixed it on windows.
Now test it work within QAtomicPtr
Change-Id: Ibf5c31a133d6d544a78ce626fac9085b73c97fd5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
57c31045df
commit
e1147dcb4b
@ -74,6 +74,7 @@ private slots:
|
||||
void fetchAndAdd_data();
|
||||
void fetchAndAdd();
|
||||
|
||||
void constAndVolatile();
|
||||
private:
|
||||
static void warningFreeHelper();
|
||||
};
|
||||
@ -657,5 +658,56 @@ void tst_QAtomicPointer::fetchAndAdd()
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> void constAndVolatile_helper()
|
||||
{
|
||||
T *one = 0;
|
||||
T *two = &one;
|
||||
T *three = &two;
|
||||
|
||||
{
|
||||
QAtomicPointer<T> atomic1 = one;
|
||||
QAtomicPointer<T> atomic2 = two;
|
||||
QAtomicPointer<T> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1.load() == one);
|
||||
QVERIFY(atomic2.load() == two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.fetchAndStoreRelaxed(two) == one);
|
||||
QVERIFY(atomic2.fetchAndStoreRelaxed(three) == two);
|
||||
QVERIFY(atomic3.fetchAndStoreRelaxed(one) == three);
|
||||
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
{
|
||||
QAtomicPointer<T> atomic1 = one;
|
||||
QAtomicPointer<T> atomic2 = two;
|
||||
QAtomicPointer<T> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1.load() == one);
|
||||
QVERIFY(atomic2.load() == two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.testAndSetRelaxed(one, two));
|
||||
QVERIFY(atomic2.testAndSetRelaxed(two, three));
|
||||
QVERIFY(atomic3.testAndSetRelaxed(three, one));
|
||||
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tst_QAtomicPointer::constAndVolatile()
|
||||
{
|
||||
constAndVolatile_helper<void>();
|
||||
constAndVolatile_helper<const void>();
|
||||
constAndVolatile_helper<volatile void>();
|
||||
constAndVolatile_helper<const volatile void>();
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QAtomicPointer)
|
||||
#include "tst_qatomicpointer.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user