X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cde76cf2a96d43f62ecb7e18c51f73e871a6d4bd..a548dafdd2f5db2e1e61be28e9430473b3124b4a:/tests/thread/atomic.cpp?ds=sidebyside diff --git a/tests/thread/atomic.cpp b/tests/thread/atomic.cpp index d49019c6ab..808ba841c9 100644 --- a/tests/thread/atomic.cpp +++ b/tests/thread/atomic.cpp @@ -23,6 +23,8 @@ #include "wx/atomic.h" #include "wx/thread.h" #include "wx/dynarray.h" +#include "wx/log.h" + WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread); // ---------------------------------------------------------------------------- @@ -59,6 +61,7 @@ private: CPPUNIT_TEST_SUITE( AtomicTestCase ); CPPUNIT_TEST( TestNoThread ); + CPPUNIT_TEST( TestDecReturn ); CPPUNIT_TEST( TestTwoThreadsMix ); CPPUNIT_TEST( TestTenThreadsMix ); CPPUNIT_TEST( TestTwoThreadsSeparate ); @@ -66,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); } @@ -95,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;