]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/thread/misc.cpp
Ignore empty LC_XXX variables in locale detection code.
[wxWidgets.git] / tests / thread / misc.cpp
index 38473a76f6a7251eb105eb3e3072ff96b7f24ad5..ecdf07df450310f85bead7ee80a1c5666d01ea25 100644 (file)
@@ -208,6 +208,7 @@ private:
         CPPUNIT_TEST( TestDetached );
         CPPUNIT_TEST( TestThreadSuspend );
         CPPUNIT_TEST( TestThreadDelete );
         CPPUNIT_TEST( TestDetached );
         CPPUNIT_TEST( TestThreadSuspend );
         CPPUNIT_TEST( TestThreadDelete );
+        CPPUNIT_TEST( TestThreadRun );
         CPPUNIT_TEST( TestThreadConditions );
         CPPUNIT_TEST( TestSemaphore );
     CPPUNIT_TEST_SUITE_END();
         CPPUNIT_TEST( TestThreadConditions );
         CPPUNIT_TEST( TestSemaphore );
     CPPUNIT_TEST_SUITE_END();
@@ -218,6 +219,7 @@ private:
 
     void TestThreadSuspend();
     void TestThreadDelete();
 
     void TestThreadSuspend();
     void TestThreadDelete();
+    void TestThreadRun();
     void TestThreadConditions();
 
     DECLARE_NO_COPY_CLASS(MiscThreadTestCase)
     void TestThreadConditions();
 
     DECLARE_NO_COPY_CLASS(MiscThreadTestCase)
@@ -226,7 +228,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( MiscThreadTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( MiscThreadTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MiscThreadTestCase, "MiscThreadTestCase" );
 
 MiscThreadTestCase::MiscThreadTestCase()
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MiscThreadTestCase, "MiscThreadTestCase" );
 
 MiscThreadTestCase::MiscThreadTestCase()
@@ -255,8 +257,8 @@ void MiscThreadTestCase::TestDetached()
         threads[n] = new MyDetachedThread(10, 'A' + n);
     }
 
         threads[n] = new MyDetachedThread(10, 'A' + n);
     }
 
-    threads[0]->SetPriority(WXTHREAD_MIN_PRIORITY);
-    threads[1]->SetPriority(WXTHREAD_MAX_PRIORITY);
+    threads[0]->SetPriority(wxPRIORITY_MIN);
+    threads[1]->SetPriority(wxPRIORITY_MAX);
 
     for ( n = 0; n < nThreads; n++ )
     {
 
     for ( n = 0; n < nThreads; n++ )
     {
@@ -320,6 +322,7 @@ void MiscThreadTestCase::TestThreadSuspend()
 
 void MiscThreadTestCase::TestThreadDelete()
 {
 
 void MiscThreadTestCase::TestThreadDelete()
 {
+    // FIXME:
     // As above, using Sleep() is only for testing here - we must use some
     // synchronisation object instead to ensure that the thread is still
     // running when we delete it - deleting a detached thread which already
     // As above, using Sleep() is only for testing here - we must use some
     // synchronisation object instead to ensure that the thread is still
     // running when we delete it - deleting a detached thread which already
@@ -345,7 +348,7 @@ void MiscThreadTestCase::TestThreadDelete()
     MyJoinableThread thread3(20);
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Run() );
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Delete() );       
     MyJoinableThread thread3(20);
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Run() );
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Delete() );       
-        // delete a joinable thread
+        // delete a joinable running thread
 
     MyJoinableThread thread4(2);
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread4.Run() );
 
     MyJoinableThread thread4(2);
     CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread4.Run() );
@@ -354,6 +357,16 @@ void MiscThreadTestCase::TestThreadDelete()
         // delete a joinable thread which already terminated
 }
 
         // delete a joinable thread which already terminated
 }
 
+void MiscThreadTestCase::TestThreadRun()
+{
+    MyJoinableThread thread1(2);
+    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread1.Run() );
+    thread1.Wait();     // wait until the thread ends
+
+    // verify that running twice the same thread fails
+    WX_ASSERT_FAILS_WITH_ASSERT( thread1.Run() );
+}
+
 void MiscThreadTestCase::TestThreadConditions()
 {
     wxMutex mutex;
 void MiscThreadTestCase::TestThreadConditions()
 {
     wxMutex mutex;