diff options
| author | Ioannis Tzavaras <tzavaras.jannis@gmail.com> | 2026-03-31 18:38:18 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-31 16:38:18 +0100 |
| commit | 179e1de50715bbb99bac15a5d38b34275106ea67 (patch) | |
| tree | 0734bd8f882858347a2baf0a4a0385bd203b5d75 /tests/desktop/rule/matchEngine/BoolMatchEngine.cpp | |
| parent | fdd2607b9b3e976f6dca1e04a8f567a7df23f1a6 (diff) | |
tests: add unit tests for match engine types (#13903)
* tests: add unit tests for match engine types
* clang-format: fix formatting in TagMatchEngine test
Diffstat (limited to 'tests/desktop/rule/matchEngine/BoolMatchEngine.cpp')
| -rw-r--r-- | tests/desktop/rule/matchEngine/BoolMatchEngine.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/desktop/rule/matchEngine/BoolMatchEngine.cpp b/tests/desktop/rule/matchEngine/BoolMatchEngine.cpp new file mode 100644 index 00000000..99f6d99c --- /dev/null +++ b/tests/desktop/rule/matchEngine/BoolMatchEngine.cpp @@ -0,0 +1,70 @@ +#include <desktop/rule/matchEngine/BoolMatchEngine.hpp> + +#include <gtest/gtest.h> + +using namespace Desktop::Rule; + +TEST(BoolMatchEngine, truthyStringOne) { + CBoolMatchEngine engine("1"); + EXPECT_TRUE(engine.match(true)); + EXPECT_FALSE(engine.match(false)); +} + +TEST(BoolMatchEngine, truthyStringTrue) { + CBoolMatchEngine engine("true"); + EXPECT_TRUE(engine.match(true)); + EXPECT_FALSE(engine.match(false)); +} + +TEST(BoolMatchEngine, truthyStringYes) { + CBoolMatchEngine engine("yes"); + EXPECT_TRUE(engine.match(true)); + EXPECT_FALSE(engine.match(false)); +} + +TEST(BoolMatchEngine, truthyStringOn) { + CBoolMatchEngine engine("on"); + EXPECT_TRUE(engine.match(true)); + EXPECT_FALSE(engine.match(false)); +} + +TEST(BoolMatchEngine, truthyCaseInsensitive) { + CBoolMatchEngine upper("TRUE"); + EXPECT_TRUE(upper.match(true)); + + CBoolMatchEngine mixed("Yes"); + EXPECT_TRUE(mixed.match(true)); + + CBoolMatchEngine onUpper("ON"); + EXPECT_TRUE(onUpper.match(true)); +} + +TEST(BoolMatchEngine, falsyStringZero) { + CBoolMatchEngine engine("0"); + EXPECT_TRUE(engine.match(false)); + EXPECT_FALSE(engine.match(true)); +} + +TEST(BoolMatchEngine, falsyStringFalse) { + CBoolMatchEngine engine("false"); + EXPECT_TRUE(engine.match(false)); + EXPECT_FALSE(engine.match(true)); +} + +TEST(BoolMatchEngine, falsyStringNo) { + CBoolMatchEngine engine("no"); + EXPECT_TRUE(engine.match(false)); + EXPECT_FALSE(engine.match(true)); +} + +TEST(BoolMatchEngine, falsyStringEmpty) { + CBoolMatchEngine engine(""); + EXPECT_TRUE(engine.match(false)); + EXPECT_FALSE(engine.match(true)); +} + +TEST(BoolMatchEngine, falsyStringArbitrary) { + CBoolMatchEngine engine("banana"); + EXPECT_TRUE(engine.match(false)); + EXPECT_FALSE(engine.match(true)); +} |
