summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qatomicpointer
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2011-11-25 10:53:38 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-29 00:07:02 +0100
commit3ad7ddf265e67c5776147a8b8b3188ef61dfe5b3 (patch)
tree323f6c4f598ee94038fb7a732b09abb5623b7b72 /tests/auto/corelib/thread/qatomicpointer
parentb36a40ac0d17fea0b299630f3e3d4174eb7ce1a9 (diff)
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 6fcfae99d3615c7a850e4933691763097078c8e4) Change-Id: I9edb2b676aedf67a252aea6a41d56cd1eef7befc Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'tests/auto/corelib/thread/qatomicpointer')
-rw-r--r--tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
index 5141bda4c2..73266205af 100644
--- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
+++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
@@ -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);