From c450ebf21b4077a19251053c1bffb5f8cba070a1 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 24 Sep 2014 16:29:21 +0100 Subject: [PATCH 5/5] match_rule_to_string: add test --- bus/signals.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bus/signals.c b/bus/signals.c index a6d8be2..1193cc3 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -2503,7 +2503,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 @@ -2516,6 +2521,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); @@ -2531,6 +2538,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 -- 1.8.5.3