[folks] Add test for parameter equality in FieldDetails.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add test for parameter equality in FieldDetails.
- Date: Fri, 12 Aug 2011 15:56:46 +0000 (UTC)
commit 13b45043d212db0efe363dd9eab4116e4d715bc7
Author: Travis Reitter <travis reitter collabora co uk>
Date: Tue Jul 12 11:48:43 2011 -0700
Add test for parameter equality in FieldDetails.
Helps: bgo#653679 - Change PostalAddressDetails.postal_addresses to
support vCard-like arbitrary parameters
tests/folks/field-details.vala | 48 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/tests/folks/field-details.vala b/tests/folks/field-details.vala
index 37e9aac..1bd9840 100644
--- a/tests/folks/field-details.vala
+++ b/tests/folks/field-details.vala
@@ -27,6 +27,7 @@ public class FieldDetailsTests : Folks.TestCase
base ("FieldDetails");
this.add_test ("parameter replacement", this.test_param_replacement);
this.add_test ("simple equality", this.test_simple_equality);
+ this.add_test ("parameter equality", this.test_params_equality);
}
public override void set_up ()
@@ -100,6 +101,53 @@ public class FieldDetailsTests : Folks.TestCase
assert (!details_b_1.equal (details_a_1));
assert (!details_b_1.equal (details_a_2));
}
+
+ public void test_params_equality ()
+ {
+ FieldDetails details_a_1 = new FieldDetails ("foo");
+ FieldDetails details_a_2 = new FieldDetails ("foo");
+
+ /* Add the parameters differently to the two instances to ensure these
+ * methods work as expected */
+ var parameters = new HashMultiMap<string, string> ();
+ parameters.set ("bar", "baz");
+ parameters.set ("qux", "quux");
+ parameters.set ("qux", "quuux");
+ details_a_1.parameters = parameters;
+
+ foreach (var param in parameters.get_keys ())
+ {
+ var values = parameters[param];
+ foreach (var value in values)
+ details_a_2.add_parameter (param, value);
+ }
+
+ assert (details_a_1.equal (details_a_2));
+
+ /* Add an existing value to a param for one object; shouldn't change */
+ details_a_2.add_parameter ("bar", "baz");
+ assert (details_a_1.equal (details_a_2));
+
+ /* Add new value to param; ensure inequality */
+ details_a_2.add_parameter ("bar", "new");
+ assert (!details_a_1.equal (details_a_2));
+
+ /* Re-set to original state */
+ details_a_2.set_parameter ("bar", "baz");
+ assert (details_a_1.equal (details_a_2));
+
+ /* Add new value to param; ensure inequality */
+ details_a_2.add_parameter ("bar", "new");
+ assert (!details_a_1.equal (details_a_2));
+
+ /* Re-set to original state (in a different way than above) */
+ details_a_2.parameters.remove ("bar", "new");
+ assert (details_a_1.equal (details_a_2));
+
+ /* Remove parameter and values; ensure inequality */
+ details_a_2.parameters.remove_all ("bar");
+ assert (!details_a_1.equal (details_a_2));
+ }
}
public int main (string[] args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]