]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
match_rule_to_string: add test
authorAlban Crequy <alban.crequy@collabora.co.uk>
Wed, 24 Sep 2014 15:29:21 +0000 (16:29 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 25 Sep 2014 11:59:50 +0000 (12:59 +0100)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
bus/signals.c

index a7e23776b6447417a61aadd13b0ef69a7d0a84bc..b283c4d9a143376c47b74f607f38c5decfcd7582 100644 (file)
@@ -2499,7 +2499,12 @@ static struct {
   { "type='method_call',arg3='foosh'", "arg3='foosh',type='method_call'" },
   { "arg3='fool'", "arg3='fool'" },
   { "arg0namespace='fool'", "arg0namespace='fool'" },
-  { "member='food'", "member='food'" }
+  { "member='food'", "member='food'" },
+  { "member=escape", "member='escape'" },
+  { "member=icecream", "member=ice'cream'" },
+  { "arg0='comma,type=comma',type=signal", "type=signal,arg0='comma,type=comma'" },
+  { "arg0=escap\\e", "arg0='escap\\e'" },
+  { "arg0=Time: 8 o\\'clock", "arg0='Time: 8 o'\\''clock'" },
 };
 
 static void
@@ -2512,6 +2517,8 @@ test_equality (void)
     {
       BusMatchRule *first;
       BusMatchRule *second;
+      char *first_str, *second_str;
+      BusMatchRule *first_reparsed, *second_reparsed;
       int j;
       
       first = check_parse (TRUE, equality_tests[i].first);
@@ -2527,6 +2534,21 @@ test_equality (void)
           exit (1);
         }
 
+      /* Check match_rule_to_string */
+      first_str = match_rule_to_string (first);
+      _dbus_assert (first_str != NULL);
+      second_str = match_rule_to_string (second);
+      _dbus_assert (second_str != NULL);
+      _dbus_assert (strcmp (first_str, second_str) == 0);
+      first_reparsed = check_parse (TRUE, first_str);
+      second_reparsed = check_parse (TRUE, second_str);
+      _dbus_assert (match_rule_equal (first, first_reparsed));
+      _dbus_assert (match_rule_equal (second, second_reparsed));
+      bus_match_rule_unref (first_reparsed);
+      bus_match_rule_unref (second_reparsed);
+      dbus_free (first_str);
+      dbus_free (second_str);
+
       bus_match_rule_unref (second);
 
       /* Check that the rule is not equal to any of the