31 #include <boost/thread.hpp>
33 #include <cxxtest/TestSuite.h>
36 #include "../WConditionOneShot.h"
90 m_testTemporary =
true;
101 TS_ASSERT_THROWS_NOTHING(
delete flag );
112 TS_ASSERT( !( *t.
flag )() );
118 ( *t.
flag )(
false );
126 TS_ASSERT( ( *t.
flag )() );
134 m_testTemporary =
false;
144 flag->
set( !flag->
get(
true ) );
148 TS_ASSERT( m_testTemporary );
151 m_testTemporary =
false;
153 flag->
set( !flag->
get(
true ), true );
154 TS_ASSERT( !m_testTemporary );
157 flag->
set( flag->
get(
true ) );
158 TS_ASSERT( !m_testTemporary );
173 bool v = flag->
get();
178 v = flag->
get(
true );
196 TS_ASSERT( flag->
get() == flagClone->
get() );
202 flagClone->
set( !flagClone->
get(
true ) );
203 TS_ASSERT( flag->
get() != flagClone->
get() );
212 #endif // WFLAG_TEST_H
boost::signals2::connection subscribeSignal(t_ConditionNotifierType notifier) const
Subscribes a specified function to be notified on condition change.
void testChangeCondition()
Test whether change condition is fired.
bool flag
Flag set to true when thread starts.
boost::shared_ptr< WCondition > getCondition()
Returns the condition that is used by this flag.
void setTemporary()
Helper function which simply sets the value above to true.
Implements a WCondition, but can be fired only ONCE.
void threadMain()
Thread function.
bool m_testTemporary
A temporary holder for some value.
bool finished
True if the thread finishes.
void testChangeFlagAndReset()
Test whether change flag is set and reset.
WFlag< bool > * flag
The flag to be tested.
void testInstantiation(void)
An instantiation should never throw an exception, as well as tear down.
virtual bool changed(bool reset=false)
True whenever the value inside this flag has changed since the last reset.
void testWaitNotify()
Test whether notification is working.
void testCopyConstruction()
Test whether copy construction/cloning is working.
virtual void wait() const
Wait for the flag to change its value.
virtual bool set(const T &value, bool suppressNotification=false)
Sets the new value for this flag.
virtual const T & get(bool resetChangeState=false)
Operator returns value of the flag.
boost::shared_ptr< WCondition > getValueChangeCondition()
Returns the condition denoting a value change.