Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 61589d1

Browse files
committedMar 7, 2024
bug fix in scripting comparison
1 parent f3a6556 commit 61589d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎include/behaviortree_cpp/scripting/operators.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct ExprComparison : ExprBase
384384
(lhs_v.isNumber() && rhs_v.isString()))
385385
{
386386
auto lv = lhs_v.cast<double>();
387-
auto rv = lhs_v.cast<double>();
387+
auto rv = rhs_v.cast<double>();
388388
if (!SwitchImpl(lv, rv, ops[i]))
389389
{
390390
return False;

‎tests/script_parser_test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ TEST(ParserTest, Equations)
228228

229229
EXPECT_EQ(GetResult(" y == x && x == 3 ").cast<int>(), 0);
230230
EXPECT_EQ(GetResult(" y == x || x == 3 ").cast<int>(), 1);
231+
232+
// we expect string to be casted to number
233+
EXPECT_EQ(GetResult(" par1:='3'; par2:=3; par1==par2").cast<int>(), 1);
234+
EXPECT_EQ(GetResult(" par1:='3'; par2:=4; par1!=par2").cast<int>(), 1);
231235
}
232236

233237

0 commit comments

Comments
 (0)
Please sign in to comment.