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/IntMatchEngine.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/IntMatchEngine.cpp')
| -rw-r--r-- | tests/desktop/rule/matchEngine/IntMatchEngine.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/desktop/rule/matchEngine/IntMatchEngine.cpp b/tests/desktop/rule/matchEngine/IntMatchEngine.cpp new file mode 100644 index 00000000..a5fb13ea --- /dev/null +++ b/tests/desktop/rule/matchEngine/IntMatchEngine.cpp @@ -0,0 +1,52 @@ +#include <desktop/rule/matchEngine/IntMatchEngine.hpp> + +#include <gtest/gtest.h> + +using namespace Desktop::Rule; + +TEST(IntMatchEngine, positiveInteger) { + CIntMatchEngine engine("42"); + EXPECT_TRUE(engine.match(42)); + EXPECT_FALSE(engine.match(41)); + EXPECT_FALSE(engine.match(0)); +} + +TEST(IntMatchEngine, zero) { + CIntMatchEngine engine("0"); + EXPECT_TRUE(engine.match(0)); + EXPECT_FALSE(engine.match(1)); +} + +TEST(IntMatchEngine, negativeInteger) { + CIntMatchEngine engine("-5"); + EXPECT_TRUE(engine.match(-5)); + EXPECT_FALSE(engine.match(5)); +} + +TEST(IntMatchEngine, invalidStringDefaultsToZero) { + CIntMatchEngine engine("abc"); + EXPECT_TRUE(engine.match(0)); + EXPECT_FALSE(engine.match(1)); +} + +TEST(IntMatchEngine, emptyStringDefaultsToZero) { + CIntMatchEngine engine(""); + EXPECT_TRUE(engine.match(0)); + EXPECT_FALSE(engine.match(1)); +} + +TEST(IntMatchEngine, leadingWhitespace) { + CIntMatchEngine engine(" 123"); + EXPECT_TRUE(engine.match(123)); +} + +TEST(IntMatchEngine, trailingNonDigits) { + CIntMatchEngine engine("123abc"); + EXPECT_TRUE(engine.match(123)); +} + +TEST(IntMatchEngine, largeValue) { + CIntMatchEngine engine("999999"); + EXPECT_TRUE(engine.match(999999)); + EXPECT_FALSE(engine.match(0)); +} |
