From 9120e8f02dc8a4b739c3fa0aefae678135e20978 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 30 Jan 2026 19:57:19 +0100 Subject: [PATCH] Add regression test for #1065: subtree string literal to LoopDouble The string value passed through a SubTree port is already type-erased (AnyTypeAllowed) per the port connection rules, and LoopNode's runtime string conversion handles the rest. This test verifies the behavior. Co-Authored-By: Claude Opus 4.5 --- tests/gtest_ports.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/gtest_ports.cpp b/tests/gtest_ports.cpp index 9ff0184b8..9644d4fa4 100644 --- a/tests/gtest_ports.cpp +++ b/tests/gtest_ports.cpp @@ -637,7 +637,7 @@ TEST(PortTest, GetInputDefaultValue_Issue858) } } -// Helper class used by Issue #969 test +// Helper class used by Issue #969 and #1065 tests class CollectDoubleAction : public SyncActionNode { public: @@ -777,3 +777,41 @@ TEST(PortTest, DefaultEmptyVector_Issue982) << " element(s). First element: \"" << (result.empty() ? "" : result[0]) << "\""; } + +// Issue #1065: passing a string literal like "1;2;3" through a SubTree port +// to a LoopDouble node should work, but fails because the subtree remapping +// stores the value as a plain std::string in the blackboard without converting +// it to SharedQueue. +TEST(PortTest, SubtreeStringLiteralToLoopDouble_Issue1065) +{ + // The main tree passes a string literal "1;2;3" to the subtree port "queue". + // Inside the subtree, LoopDouble should parse it and iterate over the values. + std::string xml_txt = R"( + + + + + + + + + + + + )"; + + std::vector collected; + + BehaviorTreeFactory factory; + factory.registerNodeType("CollectDouble", &collected); + factory.registerBehaviorTreeFromText(xml_txt); + + auto tree = factory.createTree("MainTree"); + auto status = tree.tickWhileRunning(); + + ASSERT_EQ(status, NodeStatus::SUCCESS); + ASSERT_EQ(collected.size(), 3u); + EXPECT_DOUBLE_EQ(collected[0], 1.0); + EXPECT_DOUBLE_EQ(collected[1], 2.0); + EXPECT_DOUBLE_EQ(collected[2], 3.0); +}