test_dummy_interface.cpp
Go to the documentation of this file.
1 // Bring in my package's API, which is what I'm testing
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;
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  }
18 };
19 
20 // Declare a test
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