added a test for wxAtomicDec return value
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48636 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1c06345ab6
commit
630dad8cc1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user