diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-08-27 13:50:55 +0200 |
---|---|---|
committer | Tristan Van Berkom <tristanvb@openismus.com> | 2013-10-24 23:29:46 +0200 |
commit | 105666bd26b365893510db35de100bdf24061e8b (patch) | |
tree | 7bd466adba2f689125a6e2cd8af9ad62845ea7f5 | |
parent | 6df291adc3a8b146511eac620fc1e0e50a4b26bf (diff) | |
download | evolution-data-server-openismus-work-master.tar.gz |
test-client-custom-summary.c: Added tests for transliteration queries.openismus-work-master
Added new vcard 'custom-16.vcf' with chinese words in the full name as well.
The new test tests that transliterated queries work on regular fields
as well as multi valued fields, specifically we are testing it with
E_CONTACT_EMAIL and a contact containing chinese text.
-rw-r--r-- | tests/libebook/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libebook/client/test-client-custom-summary.c | 101 | ||||
-rw-r--r-- | tests/libebook/data/vcards/custom-16.vcf | 6 |
3 files changed, 106 insertions, 2 deletions
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am index dc3663d68..f6c9d6cf8 100644 --- a/tests/libebook/Makefile.am +++ b/tests/libebook/Makefile.am @@ -97,6 +97,7 @@ EXTRA_DIST = \ $(srcdir)/data/vcards/custom-13.vcf \ $(srcdir)/data/vcards/custom-14.vcf \ $(srcdir)/data/vcards/custom-15.vcf \ + $(srcdir)/data/vcards/custom-16.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 889a6dd19..b19e50070 100644 --- a/tests/libebook/client/test-client-custom-summary.c +++ b/tests/libebook/client/test-client-custom-summary.c @@ -69,8 +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 15 - +#define N_CONTACTS 16 typedef struct { ETestServerClosure parent; @@ -758,6 +757,104 @@ 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); + + add_client_test ( + suites[i].prefix, + "/Transliterated/Prefix/Email/几", + suites[i].func, + e_book_query_field_test ( + E_CONTACT_EMAIL, + E_BOOK_QUERY_TRANSLIT_BEGINS_WITH, + "几"), + 2, + suites[i].direct, + suites[i].custom, + FALSE); + } ret = e_test_server_utils_run (); diff --git a/tests/libebook/data/vcards/custom-16.vcf b/tests/libebook/data/vcards/custom-16.vcf new file mode 100644 index 000000000..213b2e0b1 --- /dev/null +++ b/tests/libebook/data/vcards/custom-16.vcf @@ -0,0 +1,6 @@ +BEGIN:VCARD +UID:custom-16 +N:警察;懂吗 +TEL;HOME:1.800 555 PONY +EMAIL;TYPE=home,work:警察@china.net +END:VCARD |