test_rostate_machine.cpp
Go to the documentation of this file.
1 
12 // Headers in this package
14 
15 // Headers in Gtest
16 #include <gtest/gtest.h>
17 
18 // Headers in ROS
19 #include <ros/ros.h>
20 #include <ros/package.h>
21 
22 // Headers in STL
23 #include <fstream>
24 #include <iostream>
25 
26 // Declare Test
27 TEST(TestSuite, testCase1)
28 {
29  std::string xml_filepath = ros::package::getPath("rostate_machine") + std::string("/test/data/test_state_machine.xml");
30  std::ifstream ifs(xml_filepath);
31  std::string description;
32  std::string line;
33 
34  while (getline(ifs, line))
35  {
36  description += line + "\n";
37  }
38  StateMachine sm(description);
39  EXPECT_EQ(sm.getCurrentState(),"remote_operated");
40  EXPECT_EQ(sm.tryTransition("test"),false);
41  EXPECT_EQ(sm.getCurrentState(),"remote_operated");
42  EXPECT_EQ(sm.tryTransition("system_bringup"),true);
43  EXPECT_EQ(sm.getCurrentState(),"autonomous");
44 }
45 
46 // Run all the tests that were declared with TEST()
47 int main(int argc, char **argv){
48  testing::InitGoogleTest(&argc, argv);
49  return RUN_ALL_TESTS();
50 }
State Machine Class using Boost::Graph.
bool tryTransition(std::string trigger_event_name)
Try transition from trigger event.
std::string getCurrentState()
Function getting current state name.
TEST(TestSuite, testCase1)
ROSLIB_DECL std::string getPath(const std::string &package_name)
State Machine Library using Boost::Graph.
int main(int argc, char **argv)


rostate_machine
Author(s):
autogenerated on Wed Sep 4 2019 05:19:52