test: Add test for string matching
Add test for regex (?!) to not match a specific sequence.
This is useful to exclude specific matches while using
wildcard patterns.
Change-Id: I54aec4b5a956af0e815b7a57c715f4f58af8a4e6
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
diff --git a/test/test_entity-manager.cpp b/test/test_entity-manager.cpp
index 4cd841a..1f73607 100644
--- a/test/test_entity-manager.cpp
+++ b/test/test_entity-manager.cpp
@@ -267,6 +267,15 @@
EXPECT_FALSE(matchProbe(j, v));
}
+TEST(MatchProbe, stringRegexNotPrefix)
+{
+ nlohmann::json j = R"("foo(?!bar)...foo")"_json;
+ DBusValueVariant v1 = "foobarfoo"s;
+ DBusValueVariant v2 = "foofoofoo"s;
+ EXPECT_FALSE(matchProbe(j, v1));
+ EXPECT_TRUE(matchProbe(j, v2));
+}
+
TEST(MatchProbe, stringZeroNeqFalse)
{
nlohmann::json j = R"("0")"_json;