MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / TEST_F

Function TEST_F

tests/gtest_plugin_issue953.cpp:46–79  ·  view source on GitHub ↗

Test that getInput works for a custom type defined only in the plugin

Source from the content-addressed store, hash-verified

44
45// Test that getInput works for a custom type defined only in the plugin
46TEST_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
82TEST_F(PluginIssue953Test, GetInputFromBlackboardString)

Callers

nothing calls this directly

Calls 4

registerFromPluginMethod · 0.80
createTreeFromTextMethod · 0.80
tickWhileRunningMethod · 0.80
rootBlackboardMethod · 0.45

Tested by

no test coverage detected