diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-09-29 11:52:33 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-02 13:21:32 +0100 |
commit | 409b3b42a233ca58c075a75f35be5ba9b351c7de (patch) | |
tree | e88cdf48672600a4400e1566ea4405ffc38470b0 /tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp | |
parent | 3a72240d86dc85f1f2e7d47752953d83c43369c5 (diff) |
Remove cast and assignment operators from QAtomicInt and QAtomicPointer
This is a source incompatible change. There is concern that the
convenience of the implicit cast and assignment operators can lead to
misuse. Several commits have already been done that remove excess use
of the implicit cast, which is a *volatile* read every time it's used.
Users of the QAtomic* API should have to think about when they are
loading the value, and if they do or don't need the acquire memory
barrier on load. The code that people would write using this API is
meant to be multi-threaded, concurrent, and correct. The API should not
allow them to inadvertently, possibly unknowingly, shoot themselves
in the foot.
SC-break-rubber-stamped-by: Lars Knoll
Change-Id: I88fbc26d9db7b5ec80a58ad6271ffa13bbfd191f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp')
-rw-r--r-- | tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index 3c67f989f8..4606849688 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -61,14 +61,6 @@ private slots: void constructor(); void copy_constructor_data(); void copy_constructor(); - void equality_operator_data(); - void equality_operator(); - void inequality_operator_data(); - void inequality_operator(); - void not_operator_data(); - void not_operator(); - void cast_operator_data(); - void cast_operator(); void assignment_operator_data(); void assignment_operator(); @@ -185,71 +177,6 @@ void tst_QAtomicInt::copy_constructor() QCOMPARE(atomic5.load(), value); } -void tst_QAtomicInt::equality_operator_data() -{ - QTest::addColumn<int>("value1"); - QTest::addColumn<int>("value2"); - QTest::addColumn<int>("result"); - - QTest::newRow("success0") << 1 << 1 << 1; - QTest::newRow("success1") << -1 << -1 << 1; - QTest::newRow("failure0") << 0 << 1 << 0; - QTest::newRow("failure1") << 1 << 0 << 0; - QTest::newRow("failure2") << 0 << -1 << 0; - QTest::newRow("failure3") << -1 << 0 << 0; -} - -void tst_QAtomicInt::equality_operator() -{ - QFETCH(int, value1); - QFETCH(int, value2); - QAtomicInt x = value1; - QTEST(x == value2 ? 1 : 0, "result"); -} - -void tst_QAtomicInt::inequality_operator_data() -{ - QTest::addColumn<int>("value1"); - QTest::addColumn<int>("value2"); - QTest::addColumn<int>("result"); - - QTest::newRow("failure0") << 1 << 1 << 0; - QTest::newRow("failure1") << -1 << -1 << 0; - QTest::newRow("success0") << 0 << 1 << 1; - QTest::newRow("success1") << 1 << 0 << 1; - QTest::newRow("success2") << 0 << -1 << 1; - QTest::newRow("success3") << -1 << 0 << 1; -} - -void tst_QAtomicInt::inequality_operator() -{ - QFETCH(int, value1); - QFETCH(int, value2); - QAtomicInt x = value1; - QTEST(x != value2 ? 1 : 0, "result"); -} - -void tst_QAtomicInt::not_operator_data() -{ constructor_data(); } - -void tst_QAtomicInt::not_operator() -{ - QFETCH(int, value); - QAtomicInt atomic = value; - QCOMPARE(!atomic, !value); -} - -void tst_QAtomicInt::cast_operator_data() -{ constructor_data(); } - -void tst_QAtomicInt::cast_operator() -{ - QFETCH(int, value); - QAtomicInt atomic = value; - int copy = atomic; - QCOMPARE(copy, value); -} - void tst_QAtomicInt::assignment_operator_data() { QTest::addColumn<int>("value"); @@ -271,9 +198,9 @@ void tst_QAtomicInt::assignment_operator() { QAtomicInt atomic1 = value; atomic1 = newval; - QCOMPARE(int(atomic1), newval); + QCOMPARE(atomic1.load(), newval); atomic1 = value; - QCOMPARE(int(atomic1), value); + QCOMPARE(atomic1.load(), value); QAtomicInt atomic2 = newval; atomic1 = atomic2; |