From 630dad8cc1cf294f7537e898fd032231b4cb9c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 10 Sep 2007 22:12:39 +0000 Subject: [PATCH] added a test for wxAtomicDec return value git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48636 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/thread/atomic.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/thread/atomic.cpp b/tests/thread/atomic.cpp index 976266331b..808ba841c9 100644 --- a/tests/thread/atomic.cpp +++ b/tests/thread/atomic.cpp @@ -61,6 +61,7 @@ private: CPPUNIT_TEST_SUITE( AtomicTestCase ); CPPUNIT_TEST( TestNoThread ); + CPPUNIT_TEST( TestDecReturn ); CPPUNIT_TEST( TestTwoThreadsMix ); CPPUNIT_TEST( TestTenThreadsMix ); CPPUNIT_TEST( TestTwoThreadsSeparate ); @@ -68,6 +69,7 @@ private: CPPUNIT_TEST_SUITE_END(); void TestNoThread(); + void TestDecReturn(); void TestTenThreadsMix() { TestWithThreads(10, IncAndDecMixed); } void TestTwoThreadsMix() { TestWithThreads(2, IncAndDecMixed); } void TestTenThreadsSeparate() { TestWithThreads(10, IncOnly); } @@ -97,6 +99,17 @@ void AtomicTestCase::TestNoThread() CPPUNIT_ASSERT( int2 == -10000000 ); } +void AtomicTestCase::TestDecReturn() +{ + wxAtomicInt i(0); + wxAtomicInc(i); + wxAtomicInc(i); + CPPUNIT_ASSERT( i == 2 ); + + CPPUNIT_ASSERT( wxAtomicDec(i) > 0 ); + CPPUNIT_ASSERT( wxAtomicDec(i) == 0 ); +} + void AtomicTestCase::TestWithThreads(int count, ETestType testType) { wxAtomicInt int1=0;