]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/thread/atomic.cpp
Use short filenames to avoid building under a path with spaces in it.
[wxWidgets.git] / tests / thread / atomic.cpp
index d49019c6abd56717a142cac3c4345e0b0cd61a18..808ba841c9d014e3b1b4846105df6399dc5e986a 100644 (file)
@@ -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;