Commit 32211b1e authored by Pavel Vainerman's avatar Pavel Vainerman

(tests): Добавил тесты для TriggerAND

parent c3c97227
......@@ -25,6 +25,7 @@
//---------------------------------------------------------------------------
template<class Caller, typename InputType>
TriggerAND<Caller,InputType>::TriggerAND(Caller* c, Action a):
out(false),
cal(c),
act(a)
{
......@@ -84,7 +85,7 @@ template<class Caller, typename InputType>
void TriggerAND<Caller,InputType>::check()
{
bool old = out;
for( typename InputMap::iterator it=inputs.begin(); it!=inputs.end(); ++it )
for( auto it=inputs.begin(); it!=inputs.end(); ++it )
{
if( !it->second )
{
......
......@@ -52,7 +52,7 @@
...
MyClass rec;
// Создание
TriggerOR<MyClass, int> tr(&rec, &MyClass::out);
TriggerOR<MyClass> tr(&rec, &MyClass::out);
// Добавление 'входов'
tr.add(1,true);
......@@ -70,7 +70,7 @@
\endcode
*/
template<class Caller, typename InputType>
template<class Caller, typename InputType=int>
class TriggerOR
{
public:
......
......@@ -85,6 +85,7 @@ template<class Caller, typename InputType>
void TriggerOR<Caller,InputType>::check()
{
bool old = out;
for( auto it=inputs.begin(); it!=inputs.end(); ++it )
{
if( it->second )
......@@ -94,7 +95,6 @@ void TriggerOR<Caller,InputType>::check()
out = true;
if( old != out )
(cal->*act)(out);
return;
}
}
......
......@@ -42,13 +42,13 @@ TEST_CASE("TriggerOR", "[TriggerOR]" )
SECTION("Working")
{
MyTestClass tc;
TriggerOR<MyTestClass, bool> tr(&tc, &MyTestClass::setOut);
TriggerOR<MyTestClass> tr(&tc, &MyTestClass::setOut);
REQUIRE( tc.getNum() == 0 );
tr.add(1, true);
REQUIRE( tc.getNum() == 1 );
CHECK( tr.state() );
tr.add(2, false);
CHECK( tr.state() );
REQUIRE( tc.getNum() == 1 );
tr.add(3, false);
REQUIRE( tc.getNum() == 1 );
......
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