Esempio n. 1
0
    void TestThreadTerminate(void)
    {
        // Test terminating a thread
        SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
        time_t later = time(NULL) + 10;
        while (thread->IsAlive() && later > time(NULL))
            SCXCoreLib::SCXThread::Sleep(10);
        CPPUNIT_ASSERT_MESSAGE("Thread did not terminate", ! thread->IsAlive());

        // terminate again
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
    }
Esempio n. 2
0
 void TestStartTwiceFails()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     SCXUNIT_ASSERT_THROWN_EXCEPTION(thread->Start(SCXThreadTest::SimpleThreadBodyTerminate), SCXCoreLib::SCXThreadStartException, L"started");
     thread->RequestTerminate();
     thread->Wait();
 }
Esempio n. 3
0
 void callDumpStringForCoverage()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     CPPUNIT_ASSERT(thread->DumpString().find(L"SCXThread") != std::wstring::npos);
     thread->RequestTerminate();
     CPPUNIT_ASSERT(SCXCoreLib::SCXThreadParam().DumpString().find(L"SCXThreadParam") != std::wstring::npos);
 }