[evolution-data-server/openismus-work-3-8: 102/118] test-client-custom-summary.c: Added tests for transliteration queries.



commit ebe6d9a94ba2dc4b855c53e91b657635aa54a295
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Aug 27 13:50:55 2013 +0200

    test-client-custom-summary.c: Added tests for transliteration queries.
    
    Added new vcard 'custom-12.vcf' with chinese words in the full name as well.

 tests/libebook/Makefile.am                         |    1 +
 tests/libebook/client/test-client-custom-summary.c |   87 +++++++++++++++++++-
 tests/libebook/data/vcards/custom-13.vcf           |    6 ++
 3 files changed, 93 insertions(+), 1 deletions(-)
---
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index d3b47b6..75cab7e 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -94,6 +94,7 @@ EXTRA_DIST = \
        $(srcdir)/data/vcards/custom-10.vcf     \
        $(srcdir)/data/vcards/custom-11.vcf     \
        $(srcdir)/data/vcards/custom-12.vcf     \
+       $(srcdir)/data/vcards/custom-13.vcf     \
        $(NULL)
 
 test_ebook_commit_contact_LDADD=$(TEST_LIBS)
diff --git a/tests/libebook/client/test-client-custom-summary.c 
b/tests/libebook/client/test-client-custom-summary.c
index 82ac7ed..3643c26 100644
--- a/tests/libebook/client/test-client-custom-summary.c
+++ b/tests/libebook/client/test-client-custom-summary.c
@@ -69,7 +69,7 @@ static ETestServerClosure setup_default_closure = { E_TEST_SERVER_ADDRESS_BOOK,
 #  define CHECK_UNSUPPORTED_ERROR(data) (((ClientTestData *)(data))->phone_number_query != FALSE)
 #endif
 
-#define N_CONTACTS 12
+#define N_CONTACTS 13
 
 typedef struct {
        ETestServerClosure parent;
@@ -719,6 +719,91 @@ main (gint argc,
                        suites[i].direct,
                        suites[i].custom,
                        FALSE);
+
+               /*********************************************
+                *      TRANSLITERATION QUERIES FOLLOW       *
+                *********************************************/
+
+               /* We have one contact that is "Jim Morrison" and
+                * another which is "警察 懂吗" (which transliterates
+                * to "Jing cha Dong ma", which means "Police do you understand").
+                *
+                * This test tries to fetch 2 contacts beginning with '几' which
+                * transliterates to 'jǐ'.
+                *
+                * So here we assert that when searching for contacts which begin
+                * with a transliterated "几" match both "Jim Morrison" and
+                * "警察 懂吗"
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Prefix/FullName/几",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                               "几"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               /* Same results as above, only the query input is provided in Latin script */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Prefix/FullName/Ji",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                               "Ji"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               /* Check if anything contains "Ma", this should
+                * only find one match for "警察 懂吗" */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Contains/FullName/Ma",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_CONTAINS,
+                               "Ma"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Contains/FullName/Ma",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_CONTAINS,
+                               "Ma"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Suffix/FullName/Cha",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_ENDS_WITH,
+                               "Cha"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
        }
 
        ret = e_test_server_utils_run ();
diff --git a/tests/libebook/data/vcards/custom-13.vcf b/tests/libebook/data/vcards/custom-13.vcf
new file mode 100644
index 0000000..c4ecc22
--- /dev/null
+++ b/tests/libebook/data/vcards/custom-13.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:custom-13
+N:警察;懂吗
+TEL;HOME:1.800 555 PONY
+EMAIL;TYPE=home,work:dude china net
+END:VCARD


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]