From 85e556ac8ff22ce983a63d58fcd5c13396753542 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 Jun 2022 16:45:28 -0400 Subject: [PATCH] add more unit tests for boolean expressions --- unittest/commands/test_variables.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/unittest/commands/test_variables.cpp b/unittest/commands/test_variables.cpp index 35bab69c7d..29b985927d 100644 --- a/unittest/commands/test_variables.cpp +++ b/unittest/commands/test_variables.cpp @@ -403,11 +403,36 @@ TEST_F(VariableTest, IfCommand) text = END_CAPTURE_OUTPUT(); ASSERT_THAT(text, ContainsRegex(".*nope\?.*")); + BEGIN_CAPTURE_OUTPUT(); + command("if 0<1 then 'print \"bingo!\"'"); + text = END_CAPTURE_OUTPUT(); + ASSERT_THAT(text, ContainsRegex(".*bingo!.*")); + + BEGIN_CAPTURE_OUTPUT(); + command("if 2<1 then 'print \"bingo!\"' else 'print \"nope?\"'"); + text = END_CAPTURE_OUTPUT(); + ASSERT_THAT(text, ContainsRegex(".*nope\?.*")); + BEGIN_CAPTURE_OUTPUT(); command("if (1<=0) then 'print \"bingo!\"' else 'print \"nope?\"'"); text = END_CAPTURE_OUTPUT(); ASSERT_THAT(text, ContainsRegex(".*nope\?.*")); + BEGIN_CAPTURE_OUTPUT(); + command("if (0<=0) then 'print \"bingo!\"' else 'print \"nope?\"'"); + text = END_CAPTURE_OUTPUT(); + ASSERT_THAT(text, ContainsRegex(".*bingo!.*")); + + BEGIN_CAPTURE_OUTPUT(); + command("if (0>=1) then 'print \"bingo!\"' else 'print \"nope?\"'"); + text = END_CAPTURE_OUTPUT(); + ASSERT_THAT(text, ContainsRegex(".*nope\?.*")); + + BEGIN_CAPTURE_OUTPUT(); + command("if (1>=1) then 'print \"bingo!\"' else 'print \"nope?\"'"); + text = END_CAPTURE_OUTPUT(); + ASSERT_THAT(text, ContainsRegex(".*bingo!.*")); + BEGIN_CAPTURE_OUTPUT(); command("if (-1.0e-1<0.0E+0)|^(1<0) then 'print \"bingo!\"'"); text = END_CAPTURE_OUTPUT();