about summary refs log tree commit diff stats
path: root/test_prof_autocomplete.c
diff options
context:
space:
mode:
Diffstat (limited to 'test_prof_autocomplete.c')
-rw-r--r--test_prof_autocomplete.c162
1 files changed, 79 insertions, 83 deletions
diff --git a/test_prof_autocomplete.c b/test_prof_autocomplete.c
index ef867ff7..82e57eae 100644
--- a/test_prof_autocomplete.c
+++ b/test_prof_autocomplete.c
@@ -9,205 +9,202 @@
 
 static void clear_empty(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_clear(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void clear_empty_with_free_func(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void reset_after_create(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
     p_autocomplete_reset(ac);
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void find_after_create(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_complete(ac, "hello", NULL);
-    p_autocomplete_clear(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_complete(ac, "hello");
+    p_autocomplete_clear(ac);
 }
 
 static void get_after_create_returns_null(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
-    GSList *result = p_autocomplete_get_list(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_is_null(result);
 
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void get_after_create_with_copy_func_returns_null(void)
 {
-    PAutocomplete ac = p_autocomplete_new();
-    GSList *result = p_autocomplete_get_list(ac, (PCopyFunc)p_contact_copy);
+    PAutocomplete ac = p_autocomplete_new(NULL, (PCopyFunc)p_contact_copy,
+        (GDestroyNotify)p_contact_free);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_is_null(result);
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_one_and_complete(void)
 {
     char *item = strdup("Hello");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item, NULL, NULL);
-    char *result = p_autocomplete_complete(ac, "Hel", NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item);
+    char *result = p_autocomplete_complete(ac, "Hel");
 
     assert_string_equals("Hello", result);
 
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_one_and_complete_with_funcs(void)
 {
     PContact contact = p_contact_new("James", "Online", "I'm here");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact, (PStrFunc)p_contact_name, 
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, NULL, 
         (GDestroyNotify)p_contact_free);
-    char *result = p_autocomplete_complete(ac, "Jam", (PStrFunc)p_contact_name);
+    p_autocomplete_add(ac, contact);
+    char *result = p_autocomplete_complete(ac, "Jam");
 
     assert_string_equals("James", result);
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_and_complete_returns_first(void)
 {
     char *item1 = strdup("Hello");
     char *item2 = strdup("Help");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item1, NULL, NULL);
-    p_autocomplete_add(ac, item2, NULL, NULL);
-    char *result = p_autocomplete_complete(ac, "Hel", NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item1);
+    p_autocomplete_add(ac, item2);
+    char *result = p_autocomplete_complete(ac, "Hel");
 
     assert_string_equals("Hello", result);
     
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_and_complete_returns_first_with_funcs(void)
 {
     PContact contact1 = p_contact_new("James", "Online", "I'm here");
     PContact contact2 = p_contact_new("Jamie", "Away", "Out to lunch");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact1, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    p_autocomplete_add(ac, contact2, (PStrFunc)p_contact_name,
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, NULL,
         (GDestroyNotify)p_contact_free);
-    char *result = p_autocomplete_complete(ac, "Jam", (PStrFunc)p_contact_name);
+    p_autocomplete_add(ac, contact1);
+    p_autocomplete_add(ac, contact2);
+    char *result = p_autocomplete_complete(ac, "Jam");
 
     assert_string_equals("James", result);
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_and_complete_returns_second(void)
 {
     char *item1 = strdup("Hello");
     char *item2 = strdup("Help");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item1, NULL, NULL);
-    p_autocomplete_add(ac, item2, NULL, NULL);
-    char *result1 = p_autocomplete_complete(ac, "Hel", NULL);
-    char *result2 = p_autocomplete_complete(ac, result1, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item1);
+    p_autocomplete_add(ac, item2);
+    char *result1 = p_autocomplete_complete(ac, "Hel");
+    char *result2 = p_autocomplete_complete(ac, result1);
 
     assert_string_equals("Help", result2);
     
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_and_complete_returns_second_with_funcs(void)
 {
     PContact contact1 = p_contact_new("James", "Online", "I'm here");
     PContact contact2 = p_contact_new("Jamie", "Away", "Out to lunch");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact1, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    p_autocomplete_add(ac, contact2, (PStrFunc)p_contact_name,
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, NULL, 
         (GDestroyNotify)p_contact_free);
-    char *result1 = p_autocomplete_complete(ac, "Jam", (PStrFunc)p_contact_name);
-    char *result2 = p_autocomplete_complete(ac, result1, (PStrFunc)p_contact_name);
+    p_autocomplete_add(ac, contact1);
+    p_autocomplete_add(ac, contact2);
+    char *result1 = p_autocomplete_complete(ac, "Jam");
+    char *result2 = p_autocomplete_complete(ac, result1);
 
     assert_string_equals("Jamie", result2);
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_adds_two(void)
 {
     char *item1 = strdup("Hello");
     char *item2 = strdup("Help");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item1, NULL, NULL);
-    p_autocomplete_add(ac, item2, NULL, NULL);
-    GSList *result = p_autocomplete_get_list(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item1);
+    p_autocomplete_add(ac, item2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_int_equals(2, g_slist_length(result));
 
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_adds_two_with_funcs(void)
 {
     PContact contact1 = p_contact_new("James", "Online", "I'm here");
     PContact contact2 = p_contact_new("Jamie", "Away", "Out to lunch");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact1, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    p_autocomplete_add(ac, contact2, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    GSList *result = p_autocomplete_get_list(ac, (PCopyFunc)p_contact_copy);
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, 
+        (PCopyFunc)p_contact_copy, (GDestroyNotify)p_contact_free);
+    p_autocomplete_add(ac, contact1);
+    p_autocomplete_add(ac, contact2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_int_equals(2, g_slist_length(result));
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_same_adds_one(void)
 {
     char *item1 = strdup("Hello");
     char *item2 = strdup("Hello");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item1, NULL, NULL);
-    p_autocomplete_add(ac, item2, NULL, NULL);
-    GSList *result = p_autocomplete_get_list(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item1);
+    p_autocomplete_add(ac, item2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_int_equals(1, g_slist_length(result));
 
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_same_adds_one_with_funcs(void)
 {
     PContact contact1 = p_contact_new("James", "Online", "I'm here");
     PContact contact2 = p_contact_new("James", "Away", "Out to lunch");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact1, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    p_autocomplete_add(ac, contact2, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    GSList *result = p_autocomplete_get_list(ac, (PCopyFunc)p_contact_copy);
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, 
+        (PCopyFunc)p_contact_copy, (GDestroyNotify)p_contact_free);
+    p_autocomplete_add(ac, contact1);
+    p_autocomplete_add(ac, contact2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     assert_int_equals(1, g_slist_length(result));
     
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_same_updates(void)
 {
     char *item1 = strdup("Hello");
     char *item2 = strdup("Hello");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, item1, NULL, NULL);
-    p_autocomplete_add(ac, item2, NULL, NULL);
-    GSList *result = p_autocomplete_get_list(ac, NULL);
+    PAutocomplete ac = p_autocomplete_new(NULL, NULL, NULL);
+    p_autocomplete_add(ac, item1);
+    p_autocomplete_add(ac, item2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     GSList *first = g_slist_nth(result, 0);
 
@@ -215,19 +212,18 @@ static void add_two_same_updates(void)
 
     assert_string_equals("Hello", str);
 
-    p_autocomplete_clear(ac, NULL);
+    p_autocomplete_clear(ac);
 }
 
 static void add_two_same_updates_with_funcs(void)
 {
     PContact contact1 = p_contact_new("James", "Online", "I'm here");
     PContact contact2 = p_contact_new("James", "Away", "Out to lunch");
-    PAutocomplete ac = p_autocomplete_new();
-    p_autocomplete_add(ac, contact1, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    p_autocomplete_add(ac, contact2, (PStrFunc)p_contact_name,
-        (GDestroyNotify)p_contact_free);
-    GSList *result = p_autocomplete_get_list(ac, (PCopyFunc)p_contact_copy);
+    PAutocomplete ac = p_autocomplete_new((PStrFunc)p_contact_name, 
+        (PCopyFunc)p_contact_copy, (GDestroyNotify)p_contact_free);
+    p_autocomplete_add(ac, contact1);
+    p_autocomplete_add(ac, contact2);
+    GSList *result = p_autocomplete_get_list(ac);
 
     GSList *first = g_slist_nth(result, 0);
     PContact contact = first->data;
@@ -236,7 +232,7 @@ static void add_two_same_updates_with_funcs(void)
     assert_string_equals("Away", p_contact_show(contact));
     assert_string_equals("Out to lunch", p_contact_status(contact));
 
-    p_autocomplete_clear(ac, (GDestroyNotify)p_contact_free);
+    p_autocomplete_clear(ac);
 }
 
 void register_prof_autocomplete_tests(void)