[folks] Add FieldDetails tests.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add FieldDetails tests.
- Date: Wed, 2 Feb 2011 02:01:15 +0000 (UTC)
commit bc92884e49adf7d424467b6b21a9689172c02831
Author: Travis Reitter <travis reitter collabora co uk>
Date: Fri Jan 21 13:49:10 2011 -0800
Add FieldDetails tests.
Helps bgo#638279 - Add interfaces for phone, URLs, emails, etc.
configure.ac | 1 +
tests/folks/Makefile.am | 6 +++
tests/folks/field-details.vala | 86 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e355c16..8f6dbad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,7 @@ if test \
! -e ${sd}tools/folks_import_vala.stamp -o \
! -e ${sd}tests/folks/aggregation_vala.stamp -o \
! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
+ ! -e ${sd}tests/folks/field_details_vala.stamp -o \
! -e ${sd}tests/key-file/individual_retrieval_vala.stamp -o \
! -e ${sd}tests/lib/folks-test.vapi -o \
! -e ${sd}tests/lib/key-file/kf-test.vapi -o \
diff --git a/tests/folks/Makefile.am b/tests/folks/Makefile.am
index df47882..4f22112 100644
--- a/tests/folks/Makefile.am
+++ b/tests/folks/Makefile.am
@@ -39,6 +39,7 @@ AM_VALAFLAGS = \
# in order from least to most complex
noinst_PROGRAMS = \
+ field-details \
linked-hash-set \
backend-loading \
aggregation \
@@ -63,6 +64,10 @@ aggregation_SOURCES = \
aggregation.vala \
$(NULL)
+field_details_SOURCES = \
+ field-details.vala \
+ $(NULL)
+
linked_hash_set_SOURCES = \
linked-hash-set.vala \
$(NULL)
@@ -77,6 +82,7 @@ MAINTAINERCLEANFILES = \
$(addsuffix .c,$(noinst_PROGRAMS)) \
backend_loading_vala.stamp \
aggregation_vala.stamp \
+ field_details_vala.stamp \
linked_hash_set_vala.stamp \
$(NULL)
diff --git a/tests/folks/field-details.vala b/tests/folks/field-details.vala
new file mode 100644
index 0000000..113ed13
--- /dev/null
+++ b/tests/folks/field-details.vala
@@ -0,0 +1,86 @@
+using Folks;
+
+public class FieldDetailsTests : Folks.TestCase
+{
+ public FieldDetailsTests ()
+ {
+ base ("FieldDetails");
+ this.add_test ("parameter replacement", this.test_param_replacement);
+ }
+
+ public override void set_up ()
+ {
+ }
+
+ public override void tear_down ()
+ {
+ }
+
+ public void test_param_replacement ()
+ {
+ string param_name = "metasyntactic-variables";
+ string[] values_1 = {"foo", "bar", "baz"};
+ string[] values_2 = {"qux", "quxx"};
+ FieldDetails details;
+ uint i;
+ unowned GLib.List<string> values;
+
+ details = new FieldDetails (param_name);
+
+ foreach (var val in values_1)
+ details.add_parameter (param_name, val);
+
+ /* populate with first list of param values */
+ i = 0;
+ values = details.get_parameter_values (param_name);
+ assert (values.length () == values_1.length);
+ for (unowned List<string> l = values; l != null; l = l.next, i++)
+ assert (l.data == values_1[i]);
+
+ /* replace the list of param values */
+ i = 0;
+ details.set_parameter (param_name, values_2[0]);
+ values = details.get_parameter_values (param_name);
+ assert (values.length () == 1);
+ for (unowned List<string> l = values; l != null; l = l.next, i++)
+ assert (l.data == values_2[i]);
+
+ /* clear the list */
+ details.remove_parameter_all (param_name);
+ values = details.get_parameter_values (param_name);
+ assert (values == null);
+
+ /* populate with the combined list of values */
+ foreach (var val in values_1)
+ details.add_parameter (param_name, val);
+
+ var values_2_list = new GLib.List<string> ();
+ foreach (var val in values_2)
+ values_2_list.append (val);
+
+ var param_table = new HashTable<string, unowned List<string>> (str_hash,
+ str_equal);
+ param_table.insert (param_name, values_2_list);
+
+ details.extend_parameters (param_table);
+ values = details.get_parameter_values (param_name);
+ assert (values.length () == (values_1.length + values_2.length));
+ i = 0;
+ for (; i < values_1.length; i++)
+ assert (values.nth_data (i) == values_1[i]);
+ for (; i < values_2.length; i++)
+ assert (values.nth_data (i) == values_2[i]);
+ }
+}
+
+public int main (string[] args)
+{
+ Test.init (ref args);
+
+ TestSuite root = TestSuite.get_root ();
+ root.add_suite (new FieldDetailsTests ().get_suite ());
+
+ Test.run ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]