match: add utilities for match-rules

Change-Id: I47a8c6044f7275994b124e90984cbd8dbef0f0ed
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/test/bus/match.cpp b/test/bus/match.cpp
index 764392a..12d2336 100644
--- a/test/bus/match.cpp
+++ b/test/bus/match.cpp
@@ -11,11 +11,12 @@
         static constexpr auto busName =
                 "xyz.openbmc_project.sdbusplus.test.Match";
 
-        static constexpr auto matchRule =
-                "type='signal',"
-                "interface=org.freedesktop.DBus,"
-                "member='NameOwnerChanged',"
-                "arg0='xyz.openbmc_project.sdbusplus.test.Match'";
+
+        static auto matchRule()
+        {
+            using namespace sdbusplus::bus::match::rules;
+            return nameOwnerChanged() + argN(0, busName);
+        }
 
         void waitForIt(bool& triggered)
         {
@@ -36,7 +37,7 @@
             return 0;
         };
 
-    sdbusplus::bus::match_t m{bus, matchRule, trigger, &triggered};
+    sdbusplus::bus::match_t m{bus, matchRule().c_str(), trigger, &triggered};
     auto m2 = std::move(m);  // ensure match is move-safe.
 
     waitForIt(triggered);
@@ -56,7 +57,7 @@
             triggered = true;
         };
 
-    sdbusplus::bus::match_t m{bus, matchRule, trigger};
+    sdbusplus::bus::match_t m{bus, matchRule().c_str(), trigger};
     auto m2 = std::move(m);  // ensure match is move-safe.
 
     waitForIt(triggered);
@@ -83,7 +84,7 @@
     };
     BoolHolder b;
 
-    sdbusplus::bus::match_t m{bus, matchRule,
+    sdbusplus::bus::match_t m{bus, matchRule().c_str(),
                               std::bind(std::mem_fn(&BoolHolder::callback),
                                         &b, std::placeholders::_1)};
     auto m2 = std::move(m);  // ensure match is move-safe.