Fix crash in tst_qatomicpointer test
if given char*, QCOMPARE will try to compare the strings pointed by the
char*
In this case, the char* just point to garbage, we just want to compare
the addresses.
(Was changed in commit 6fcfae99d3
)
Change-Id: I9edb2b676aedf67a252aea6a41d56cd1eef7befc
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
parent
b36a40ac0d
commit
3ad7ddf265
@ -599,9 +599,10 @@ void tst_QAtomicPointer::fetchAndAdd()
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(pointer1.fetchAndAddRelaxed(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddRelaxed(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
// cast to void* in order to avoid QCOMPARE to compare string content of the char*
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelaxed(valueToAdd)), static_cast<void*>(pc));
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelaxed(-valueToAdd)), static_cast<void*>(pc + valueToAdd));
|
||||
QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc));
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(pointer2.fetchAndAddRelaxed(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddRelaxed(-valueToAdd), ps + valueToAdd);
|
||||
@ -614,9 +615,9 @@ void tst_QAtomicPointer::fetchAndAdd()
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(pointer1.fetchAndAddAcquire(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddAcquire(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddAcquire(valueToAdd)), static_cast<void*>(pc));
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddAcquire(-valueToAdd)), static_cast<void*>(pc + valueToAdd));
|
||||
QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc));
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(pointer2.fetchAndAddAcquire(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddAcquire(-valueToAdd), ps + valueToAdd);
|
||||
@ -629,9 +630,9 @@ void tst_QAtomicPointer::fetchAndAdd()
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(pointer1.fetchAndAddRelease(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddRelease(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelease(valueToAdd)), static_cast<void*>(pc));
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelease(-valueToAdd)), static_cast<void*>(pc + valueToAdd));
|
||||
QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc));
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(pointer2.fetchAndAddRelease(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddRelease(-valueToAdd), ps + valueToAdd);
|
||||
@ -644,9 +645,9 @@ void tst_QAtomicPointer::fetchAndAdd()
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(pointer1.fetchAndAddOrdered(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddOrdered(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddOrdered(valueToAdd)), static_cast<void*>(pc));
|
||||
QCOMPARE(static_cast<void*>(pointer1.fetchAndAddOrdered(-valueToAdd)), static_cast<void*>(pc + valueToAdd));
|
||||
QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc));
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(pointer2.fetchAndAddOrdered(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddOrdered(-valueToAdd), ps + valueToAdd);
|
||||
|
Loading…
Reference in New Issue
Block a user