Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
32211b1e
Commit
32211b1e
authored
Oct 08, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(tests): Добавил тесты для TriggerAND
parent
c3c97227
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
TriggerAND.tcc
include/TriggerAND.tcc
+2
-1
TriggerOR.h
include/TriggerOR.h
+2
-2
TriggerOR.tcc
include/TriggerOR.tcc
+1
-1
triggerOR.cc
tests/triggerOR.cc
+2
-2
No files found.
include/TriggerAND.tcc
View file @
32211b1e
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
template<class Caller, typename InputType>
template<class Caller, typename InputType>
TriggerAND<Caller,InputType>::TriggerAND(Caller* c, Action a):
TriggerAND<Caller,InputType>::TriggerAND(Caller* c, Action a):
out(false),
cal(c),
cal(c),
act(a)
act(a)
{
{
...
@@ -84,7 +85,7 @@ template<class Caller, typename InputType>
...
@@ -84,7 +85,7 @@ template<class Caller, typename InputType>
void TriggerAND<Caller,InputType>::check()
void TriggerAND<Caller,InputType>::check()
{
{
bool old = out;
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 )
if( !it->second )
{
{
...
...
include/TriggerOR.h
View file @
32211b1e
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
...
...
MyClass rec;
MyClass rec;
// Создание
// Создание
TriggerOR<MyClass
, int
> tr(&rec, &MyClass::out);
TriggerOR<MyClass> tr(&rec, &MyClass::out);
// Добавление 'входов'
// Добавление 'входов'
tr.add(1,true);
tr.add(1,true);
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
\endcode
\endcode
*/
*/
template
<
class
Caller
,
typename
InputType
>
template
<
class
Caller
,
typename
InputType
=
int
>
class
TriggerOR
class
TriggerOR
{
{
public
:
public
:
...
...
include/TriggerOR.tcc
View file @
32211b1e
...
@@ -85,6 +85,7 @@ template<class Caller, typename InputType>
...
@@ -85,6 +85,7 @@ template<class Caller, typename InputType>
void TriggerOR<Caller,InputType>::check()
void TriggerOR<Caller,InputType>::check()
{
{
bool old = out;
bool old = out;
for( auto it=inputs.begin(); it!=inputs.end(); ++it )
for( auto it=inputs.begin(); it!=inputs.end(); ++it )
{
{
if( it->second )
if( it->second )
...
@@ -94,7 +95,6 @@ void TriggerOR<Caller,InputType>::check()
...
@@ -94,7 +95,6 @@ void TriggerOR<Caller,InputType>::check()
out = true;
out = true;
if( old != out )
if( old != out )
(cal->*act)(out);
(cal->*act)(out);
return;
return;
}
}
}
}
...
...
tests/triggerOR.cc
View file @
32211b1e
...
@@ -42,13 +42,13 @@ TEST_CASE("TriggerOR", "[TriggerOR]" )
...
@@ -42,13 +42,13 @@ TEST_CASE("TriggerOR", "[TriggerOR]" )
SECTION
(
"Working"
)
SECTION
(
"Working"
)
{
{
MyTestClass
tc
;
MyTestClass
tc
;
TriggerOR
<
MyTestClass
,
bool
>
tr
(
&
tc
,
&
MyTestClass
::
setOut
);
TriggerOR
<
MyTestClass
>
tr
(
&
tc
,
&
MyTestClass
::
setOut
);
REQUIRE
(
tc
.
getNum
()
==
0
);
REQUIRE
(
tc
.
getNum
()
==
0
);
tr
.
add
(
1
,
true
);
tr
.
add
(
1
,
true
);
REQUIRE
(
tc
.
getNum
()
==
1
);
REQUIRE
(
tc
.
getNum
()
==
1
);
CHECK
(
tr
.
state
()
);
CHECK
(
tr
.
state
()
);
tr
.
add
(
2
,
false
);
tr
.
add
(
2
,
false
);
CHECK
(
tr
.
state
()
);
REQUIRE
(
tc
.
getNum
()
==
1
);
REQUIRE
(
tc
.
getNum
()
==
1
);
tr
.
add
(
3
,
false
);
tr
.
add
(
3
,
false
);
REQUIRE
(
tc
.
getNum
()
==
1
);
REQUIRE
(
tc
.
getNum
()
==
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment