test_dummy_interface.cpp
Go to the documentation of this file.
00001 // Bring in my package's API, which is what I'm testing
00002 #include <socketcan_interface/dispatcher.h>
00003 #include <socketcan_interface/dummy.h>
00004 
00005 // Bring in gtest
00006 #include <gtest/gtest.h>
00007 
00008 class DummyInterfaceTest : public ::testing::Test{
00009 public:
00010     std::list<std::string> responses;
00011     can::DummyInterface dummy;
00012     DummyInterfaceTest() : dummy(true), listener(dummy.createMsgListener(can::CommInterface::FrameDelegate(this, &DummyInterfaceTest::handle ))) { }
00013 
00014    void handle(const can::Frame &f){
00015         responses.push_back(can::tostring(f, true));
00016     }
00017     can::CommInterface::FrameListener::Ptr listener;
00018 };
00019 
00020 // Declare a test
00021 TEST_F(DummyInterfaceTest, testCase1)
00022 {
00023     dummy.add("0#8200", "701#00" ,false);
00024 
00025     std::list<std::string> expected;
00026 
00027     dummy.send(can::toframe("0#8200"));
00028     expected.push_back("0#8200");
00029     expected.push_back("701#00");
00030 
00031     EXPECT_EQ(expected, responses);
00032 }
00033 
00034 
00035 // Run all the tests that were declared with TEST()
00036 int main(int argc, char **argv){
00037 testing::InitGoogleTest(&argc, argv);
00038 return RUN_ALL_TESTS();
00039 }


socketcan_interface
Author(s): Mathias L├╝dtke
autogenerated on Thu Jun 6 2019 20:43:53