Test that getInput works for a custom type defined only in the plugin
| 44 | |
| 45 | // Test that getInput works for a custom type defined only in the plugin |
| 46 | TEST_F(PluginIssue953Test, GetInputUsesStoredConverter) |
| 47 | { |
| 48 | // This XML uses a literal string value for the input port |
| 49 | const char* xml_text = R"( |
| 50 | <root BTCPP_format="4"> |
| 51 | <BehaviorTree ID="MainTree"> |
| 52 | <Issue953Action input="42;hello_world;3.14159"/> |
| 53 | </BehaviorTree> |
| 54 | </root> |
| 55 | )"; |
| 56 | |
| 57 | BehaviorTreeFactory factory; |
| 58 | |
| 59 | // Load the plugin - this registers Issue953Action |
| 60 | // The plugin has the convertFromString<Issue953Type> specialization, |
| 61 | // but THIS file does not. |
| 62 | factory.registerFromPlugin(plugin_path_); |
| 63 | |
| 64 | auto tree = factory.createTreeFromText(xml_text); |
| 65 | |
| 66 | // This should work because: |
| 67 | // 1. InputPort<Issue953Type>() was called in the plugin |
| 68 | // 2. GetAnyFromStringFunctor captured convertFromString at that point |
| 69 | // 3. The fix makes getInput() use that stored converter |
| 70 | auto status = tree.tickWhileRunning(); |
| 71 | |
| 72 | ASSERT_EQ(status, NodeStatus::SUCCESS); |
| 73 | |
| 74 | // Verify the parsed values via output ports |
| 75 | auto bb = tree.rootBlackboard(); |
| 76 | EXPECT_EQ(bb->get<int>("out_id"), 42); |
| 77 | EXPECT_EQ(bb->get<std::string>("out_name"), "hello_world"); |
| 78 | EXPECT_DOUBLE_EQ(bb->get<double>("out_value"), 3.14159); |
| 79 | } |
| 80 | |
| 81 | // Test with blackboard - value stored as string, then parsed on read |
| 82 | TEST_F(PluginIssue953Test, GetInputFromBlackboardString) |
nothing calls this directly
no test coverage detected