Main Page
Namespaces
Namespace List
Namespace Members
All
b
c
d
f
h
o
s
t
Functions
Typedefs
Classes
Class List
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
w
x
~
Variables
b
c
d
e
f
g
i
l
m
r
s
t
v
Typedefs
Enumerations
Enumerator
Files
File List
File Members
All
_
a
c
f
g
l
m
p
r
t
Functions
Variables
Macros
test
test_dummy_interface.cpp
Go to the documentation of this file.
1
// Bring in my package's API, which is what I'm testing
2
#include <
socketcan_interface/dispatcher.h
>
3
#include <
socketcan_interface/dummy.h
>
4
5
// Bring in gtest
6
#include <gtest/gtest.h>
7
8
class
DummyInterfaceTest
:
public
::testing::Test{
9
public
:
10
std::list<std::string>
responses
;
11
can::DummyInterface
dummy
;
12
DummyInterfaceTest
() :
dummy
(true),
listener
(
dummy
.createMsgListenerM(this, &
DummyInterfaceTest
::
handle
)) { }
13
14
void
handle
(
const
can::Frame
&f){
15
responses
.push_back(
can::tostring
(f,
true
));
16
}
17
can::FrameListenerConstSharedPtr
listener
;
18
};
19
20
// Declare a test
21
TEST_F
(
DummyInterfaceTest
, testCase1)
22
{
23
dummy.add(
"0#8200"
,
"701#00"
,
false
);
24
25
std::list<std::string> expected;
26
27
dummy.send(
can::toframe
(
"0#8200"
));
28
expected.push_back(
"0#8200"
);
29
expected.push_back(
"701#00"
);
30
31
EXPECT_EQ(expected, responses);
32
}
33
34
35
// Run all the tests that were declared with TEST()
36
int
main
(
int
argc,
char
**argv){
37
testing::InitGoogleTest(&argc, argv);
38
return
RUN_ALL_TESTS();
39
}
DummyInterfaceTest::listener
can::FrameListenerConstSharedPtr listener
Definition:
test_dummy_interface.cpp:17
can::Frame
Definition:
interface.h:62
can::tostring
std::string tostring(const Header &h, bool lc)
Definition:
string.cpp:78
can::DummyInterface
Definition:
dummy.h:13
dispatcher.h
TEST_F
TEST_F(DummyInterfaceTest, testCase1)
Definition:
test_dummy_interface.cpp:21
DummyInterfaceTest::responses
std::list< std::string > responses
Definition:
test_dummy_interface.cpp:10
dummy.h
DummyInterfaceTest::dummy
can::DummyInterface dummy
Definition:
test_dummy_interface.cpp:11
main
int main(int argc, char **argv)
Definition:
test_dummy_interface.cpp:36
DummyInterfaceTest
Definition:
test_dummy_interface.cpp:8
DummyInterfaceTest::handle
void handle(const can::Frame &f)
Definition:
test_dummy_interface.cpp:14
can::toframe
Frame toframe(const std::string &s)
Definition:
string.cpp:119
can::FrameListenerConstSharedPtr
CommInterface::FrameListenerConstSharedPtr FrameListenerConstSharedPtr
Definition:
interface.h:176
DummyInterfaceTest::DummyInterfaceTest
DummyInterfaceTest()
Definition:
test_dummy_interface.cpp:12
socketcan_interface
Author(s): Mathias Lüdtke
autogenerated on Wed Mar 2 2022 00:52:25