| 41 | } // namespace |
| 42 | |
| 43 | struct SwitchTest : testing::Test |
| 44 | { |
| 45 | using Switch2 = BT::SwitchNode<2>; |
| 46 | std::unique_ptr<Switch2> root; |
| 47 | BT::AsyncActionTest action_1; |
| 48 | BT::AsyncActionTest action_42; |
| 49 | BT::AsyncActionTest action_def; |
| 50 | BT::Blackboard::Ptr bb = BT::Blackboard::create(); |
| 51 | BT::NodeConfig simple_switch_config_; |
| 52 | |
| 53 | SwitchTest() |
| 54 | : action_1("action_1", milliseconds(200)) |
| 55 | , action_42("action_42", milliseconds(200)) |
| 56 | , action_def("action_default", milliseconds(200)) |
| 57 | { |
| 58 | BT::PortsRemapping input; |
| 59 | input.insert(std::make_pair("variable", "{my_var}")); |
| 60 | input.insert(std::make_pair("case_1", "1")); |
| 61 | input.insert(std::make_pair("case_2", "42")); |
| 62 | |
| 63 | BT::NodeConfig simple_switch_config_; |
| 64 | simple_switch_config_.blackboard = bb; |
| 65 | simple_switch_config_.input_ports = input; |
| 66 | |
| 67 | root = std::make_unique<Switch2>("simple_switch", simple_switch_config_); |
| 68 | |
| 69 | root->addChild(&action_1); |
| 70 | root->addChild(&action_42); |
| 71 | root->addChild(&action_def); |
| 72 | } |
| 73 | ~SwitchTest() override |
| 74 | { |
| 75 | root->halt(); |
| 76 | } |
| 77 | SwitchTest(const SwitchTest&) = delete; |
| 78 | SwitchTest& operator=(const SwitchTest&) = delete; |
| 79 | SwitchTest(SwitchTest&&) = delete; |
| 80 | SwitchTest& operator=(SwitchTest&&) = delete; |
| 81 | }; |
| 82 | |
| 83 | TEST_F(SwitchTest, DefaultCase) |
| 84 | { |