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.createMsgListener(can::CommInterface::FrameDelegate(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 }
TEST_F(DummyInterfaceTest, testCase1)
std::string tostring(const Header &h, bool lc)
Definition: string.cpp:77
Definition: asio_base.h:11
Frame toframe(const std::string &s)
Definition: string.cpp:114
std::list< std::string > responses
void handle(const can::Frame &f)
CommInterface::FrameListenerConstSharedPtr FrameListenerConstSharedPtr
Definition: interface.h:160
can::FrameListenerConstSharedPtr listener
bool add(const std::string &k, const Frame &v, bool multi)
Definition: dummy.h:31
int main(int argc, char **argv)
can::DummyInterface dummy
virtual bool send(const Frame &msg)
Definition: dummy.h:43


socketcan_interface
Author(s): Mathias Lüdtke
autogenerated on Fri May 14 2021 02:59:39