From 0f296eeae20d502b9f9e6f48c18e6339dd7b2987 Mon Sep 17 00:00:00 2001 From: mmporong Date: Sat, 31 Oct 2026 23:38:13 +0900 Subject: [PATCH] =?UTF-8?q?fix(control):=20=EA=B1=B4=EB=84=88=EB=9B=B4=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=83=81=ED=83=9C=EB=A5=BC=20=EC=A0=84?= =?UTF-8?q?=ED=8C=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controls/if_then_else_node.cpp | 5 +++++ src/controls/while_do_else_node.cpp | 5 +++++ tests/gtest_if_then_else.cpp | 21 +++++++++++++++++++++ tests/gtest_while_do_else.cpp | 21 +++++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/src/controls/if_then_else_node.cpp b/src/controls/if_then_else_node.cpp index 7d33099c6..3532c3f6c 100644 --- a/src/controls/if_then_else_node.cpp +++ b/src/controls/if_then_else_node.cpp @@ -45,6 +45,11 @@ NodeStatus IfThenElseNode::tick() { return condition_status; } + if(condition_status == NodeStatus::SKIPPED) + { + resetChildren(); + return condition_status; + } if(condition_status == NodeStatus::SUCCESS) { child_idx_ = 1; diff --git a/src/controls/while_do_else_node.cpp b/src/controls/while_do_else_node.cpp index 40c58086e..b7035a931 100644 --- a/src/controls/while_do_else_node.cpp +++ b/src/controls/while_do_else_node.cpp @@ -42,6 +42,11 @@ NodeStatus WhileDoElseNode::tick() { return condition_status; } + if(condition_status == NodeStatus::SKIPPED) + { + resetChildren(); + return condition_status; + } NodeStatus status = NodeStatus::IDLE; diff --git a/tests/gtest_if_then_else.cpp b/tests/gtest_if_then_else.cpp index 44fecf7c9..61e000db3 100644 --- a/tests/gtest_if_then_else.cpp +++ b/tests/gtest_if_then_else.cpp @@ -174,6 +174,27 @@ TEST_F(IfThenElseTest, ConditionRunning) ASSERT_EQ(counters[0], 1); // TestA executed } +TEST_F(IfThenElseTest, ConditionSkipped) +{ + const std::string xml_text = R"( + + + + + + + + + )"; + + auto tree = factory.createTreeFromText(xml_text); + auto status = tree.tickOnce(); + + ASSERT_EQ(status, NodeStatus::SKIPPED); + ASSERT_EQ(counters[0], 0); + ASSERT_EQ(counters[1], 0); +} + TEST_F(IfThenElseTest, HaltBehavior) { // Test that halt resets the node properly diff --git a/tests/gtest_while_do_else.cpp b/tests/gtest_while_do_else.cpp index 3b08644c3..6c9fd1eb9 100644 --- a/tests/gtest_while_do_else.cpp +++ b/tests/gtest_while_do_else.cpp @@ -94,6 +94,27 @@ TEST_F(WhileDoElseTest, ConditionFalse_TwoChildren_ReturnsFailure) ASSERT_EQ(counters[0], 0); // TestA not executed } +TEST_F(WhileDoElseTest, ConditionSkipped) +{ + const std::string xml_text = R"( + + + + + + + + + )"; + + auto tree = factory.createTreeFromText(xml_text); + auto status = tree.tickOnce(); + + ASSERT_EQ(status, NodeStatus::SKIPPED); + ASSERT_EQ(counters[0], 0); + ASSERT_EQ(counters[1], 0); +} + TEST_F(WhileDoElseTest, DoBranchFails) { // When do-branch fails, WhileDoElse returns FAILURE