Fixed test-client-custom-summary to actually pass
authorTristan Van Berkom <tristanvb@openismus.com>
Fri, 7 Dec 2012 09:00:42 +0000 (18:00 +0900)
committerTristan Van Berkom <tristanvb@openismus.com>
Fri, 7 Dec 2012 09:00:42 +0000 (18:00 +0900)
Was missing a vcard modification to test for EVC_N component, also
enhanced test case to test both apis for each case and added one
case to check the special '%' escape char is working.

tests/libebook/client/test-client-custom-summary.c
tests/libebook/data/vcards/custom-2.vcf
tests/libebook/data/vcards/custom-6.vcf [new file with mode: 0644]

index b2fbbea..d308253 100644 (file)
@@ -138,7 +138,9 @@ client_test_data_free (gpointer p)
 {
        ClientTestData *const data = p;
        g_object_unref (data->client);
-       e_book_query_unref (data->query);
+
+       if (data->query)
+               e_book_query_unref (data->query);
        g_slice_free (ClientTestData, data);
 }
 
@@ -235,23 +237,12 @@ main (gint argc,
        }
 
        /* Add contacts */
-       if (!add_contact_from_test_case_verify (book_client, "custom-1", &contact_final)) {
-               g_object_unref (book_client);
-               return 1;
-       }
-       if (!add_contact_from_test_case_verify (book_client, "custom-2", &contact_final)) {
-               g_object_unref (book_client);
-               return 1;
-       }
-       if (!add_contact_from_test_case_verify (book_client, "custom-3", &contact_final)) {
-               g_object_unref (book_client);
-               return 1;
-       }
-       if (!add_contact_from_test_case_verify (book_client, "custom-4", &contact_final)) {
-               g_object_unref (book_client);
-               return 1;
-       }
-       if (!add_contact_from_test_case_verify (book_client, "custom-5", &contact_final)) {
+       if (!add_contact_from_test_case_verify (book_client, "custom-1", &contact_final) ||
+           !add_contact_from_test_case_verify (book_client, "custom-2", &contact_final) ||
+           !add_contact_from_test_case_verify (book_client, "custom-3", &contact_final) ||
+           !add_contact_from_test_case_verify (book_client, "custom-4", &contact_final) ||
+           !add_contact_from_test_case_verify (book_client, "custom-5", &contact_final) ||
+           !add_contact_from_test_case_verify (book_client, "custom-6", &contact_final)) {
                g_object_unref (book_client);
                return 1;
        }
@@ -260,21 +251,39 @@ main (gint argc,
        add_client_test ("/client/search/exact/fn", search_test, book_client,
                         e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_IS, "James Brown"),
                         1);
+       add_client_test ("/client/search/exact/name", search_test, book_client,
+                        e_book_query_vcard_field_test(EVC_N, E_BOOK_QUERY_IS, "Janet"),
+                        1);
        add_client_test ("/client/search/prefix/fn", search_test, book_client,
                         e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, "B"),
                         2);
+       add_client_test ("/client/search/prefix/fn/percent", search_test, book_client,
+                        e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, "%"),
+                        1);
        add_client_test ("/client/search/suffix/phone", search_test, book_client,
                         e_book_query_field_test (E_CONTACT_TEL, E_BOOK_QUERY_ENDS_WITH, "999"),
                         2);
        add_client_test ("/client/search/suffix/email", search_test, book_client,
                         e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_ENDS_WITH, "jackson.com"),
                         2);
-       add_client_test ("/client/search/exact/name", search_test, book_client,
-                        e_book_query_vcard_field_test(EVC_N, E_BOOK_QUERY_IS, "Janet"),
-                        1);
 
        /* Add search tests that fetch uids */
+       add_client_test ("/client/search-uid/exact/fn", uid_test, book_client,
+                        e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_IS, "James Brown"),
+                        1);
        add_client_test ("/client/search-uid/exact/name", uid_test, book_client,
+                        e_book_query_vcard_field_test(EVC_N, E_BOOK_QUERY_IS, "Janet"),
+                        1);
+       add_client_test ("/client/search-uid/prefix/fn", uid_test, book_client,
+                        e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, "B"),
+                        2);
+       add_client_test ("/client/search-uid/prefix/fn/percent", uid_test, book_client,
+                        e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, "%"),
+                        1);
+       add_client_test ("/client/search-uid/suffix/phone", uid_test, book_client,
+                        e_book_query_field_test (E_CONTACT_TEL, E_BOOK_QUERY_ENDS_WITH, "999"),
+                        2);
+       add_client_test ("/client/search-uid/suffix/email", uid_test, book_client,
                         e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_ENDS_WITH, "jackson.com"),
                         2);
 
index c267827..56c5dd6 100644 (file)
@@ -1,5 +1,6 @@
 BEGIN:VCARD
 FN:Janet Jackson
+N:Janet
 TEL;HOME:+7654321
 EMAIL:janet@jackson.com
 EMAIL:janny@jackson.com
diff --git a/tests/libebook/data/vcards/custom-6.vcf b/tests/libebook/data/vcards/custom-6.vcf
new file mode 100644 (file)
index 0000000..d64650e
--- /dev/null
@@ -0,0 +1,3 @@
+BEGIN:VCARD
+FN:%Strange Name
+END:VCARD