Commit f863e5aa authored by reichenbach's avatar reichenbach

[FIX] another change to some unittests

parent 92090ef2
......@@ -51,6 +51,7 @@ class WThreadedFunctionTest : public CxxTest::TestSuite
{
// init stuff here
m_result.getWriteTicket()->get() = 0;
m_stopped.getWriteTicket()->get() = false;
if( value < 0 )
{
......@@ -71,9 +72,17 @@ class WThreadedFunctionTest : public CxxTest::TestSuite
}
if( shutdown() )
{
m_result.getWriteTicket()->get() = -1;
m_stopped.getWriteTicket()->get() = true;
}
sleep( 1 );
}
/**
* Check if the thread was ordered to stop.
* \return true, if the thread was ordered to stop
*/
bool stopped()
{
return m_stopped.getReadTicket()->get();
}
/**
......@@ -101,6 +110,9 @@ class WThreadedFunctionTest : public CxxTest::TestSuite
//! the result
WSharedObject< int > m_result;
//! thread stopped?
WSharedObject< bool > m_stopped;
};
/**
......@@ -184,7 +196,7 @@ public:
*/
void testStopThreads()
{
boost::shared_ptr< FuncType > func( new FuncType( 100 ) );
boost::shared_ptr< FuncType > func( new FuncType( 100000000 ) );
WThreadedFunction< FuncType > f( 6, func );
TS_ASSERT_EQUALS( f.status(), W_THREADS_INITIALIZED );
......@@ -195,7 +207,7 @@ public:
f.wait();
TS_ASSERT_EQUALS( f.status(), W_THREADS_ABORTED );
TS_ASSERT_EQUALS( func->getResult(), -1 );
TS_ASSERT( func->stopped() );
func->reset();
}
......
......@@ -51,6 +51,7 @@ class WWorkerThreadTest : public CxxTest::TestSuite
{
// init stuff here
m_result.getWriteTicket()->get() = 0;
m_stopped.getWriteTicket()->get() = false;
if( value < 0 )
{
......@@ -71,10 +72,19 @@ class WWorkerThreadTest : public CxxTest::TestSuite
}
if( shutdown() )
{
m_result.getWriteTicket()->get() = -1;
m_stopped.getWriteTicket()->get() = true;
}
}
/**
* Check if the thread was ordered to stop.
* \return true, if the thread was ordered to stop
*/
bool stopped()
{
return m_stopped.getReadTicket()->get();
}
/**
* A method to extract the result.
*
......@@ -85,6 +95,14 @@ class WWorkerThreadTest : public CxxTest::TestSuite
return m_result.getReadTicket()->get();
}
/**
* Reset everything.
*/
void reset()
{
m_result.getWriteTicket()->get() = 0;
}
private:
//! the input data
......@@ -92,6 +110,9 @@ class WWorkerThreadTest : public CxxTest::TestSuite
//! the result
WSharedObject< int > m_result;
//! thread stopped?
WSharedObject< bool > m_stopped;
};
/**
......@@ -137,7 +158,7 @@ public:
{
m_stopped = false;
boost::shared_ptr< FuncType > func( new FuncType( 60 ) );
boost::shared_ptr< FuncType > func( new FuncType( 100000000 ) );
WWorkerThread< FuncType > w( func, 0, 1 );
w.subscribeStopSignal( boost::bind( &WWorkerThreadTest::stopTestDone, this ) );
......@@ -145,7 +166,7 @@ public:
w.requestStop();
w.wait();
TS_ASSERT_EQUALS( func->getResult(), -1 );
TS_ASSERT( func->stopped() );
TS_ASSERT_EQUALS( m_stopped, true );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment