Skip to content

Commit

Permalink
bug fix in scripting comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Mar 7, 2024
1 parent f3a6556 commit 61589d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/behaviortree_cpp/scripting/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ struct ExprComparison : ExprBase
(lhs_v.isNumber() && rhs_v.isString()))
{
auto lv = lhs_v.cast<double>();
auto rv = lhs_v.cast<double>();
auto rv = rhs_v.cast<double>();
if (!SwitchImpl(lv, rv, ops[i]))
{
return False;
Expand Down
4 changes: 4 additions & 0 deletions tests/script_parser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ TEST(ParserTest, Equations)

EXPECT_EQ(GetResult(" y == x && x == 3 ").cast<int>(), 0);
EXPECT_EQ(GetResult(" y == x || x == 3 ").cast<int>(), 1);

// we expect string to be casted to number
EXPECT_EQ(GetResult(" par1:='3'; par2:=3; par1==par2").cast<int>(), 1);
EXPECT_EQ(GetResult(" par1:='3'; par2:=4; par1!=par2").cast<int>(), 1);
}


Expand Down

0 comments on commit 61589d1

Please sign in to comment.