[evolution-data-server/openismus-work-3-8: 111/116] test-client-cursor-operations.c: Added tests for using transliterated queries



commit f0a2d1bfd2b28d35017bb822a935f01965b71dc9
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Fri Aug 30 15:29:38 2013 +0200

    test-client-cursor-operations.c: Added tests for using transliterated queries
    
    Since the cursor requires that all fields in use be summarized in the
    SQLite summary columns, this test also ensures that transliterated queries
    are summarized (and don't fall back on EBookBackendSexp).

 .../client/test-client-cursor-operations.c         |   41 ++++++++++++++++++++
 tests/libebook/data/vcards/sorted-4.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-5.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-9.vcf            |    2 +-
 4 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/tests/libebook/client/test-client-cursor-operations.c 
b/tests/libebook/client/test-client-cursor-operations.c
index 5a68d47..3fcbef0 100644
--- a/tests/libebook/client/test-client-cursor-operations.c
+++ b/tests/libebook/client/test-client-cursor-operations.c
@@ -2259,6 +2259,47 @@ main (gint argc,
                cursor_closure_position (closure, 13, 6, TRUE);
                cursor_closure_add (closure, "/EBookClientCursor/SearchExpression/EffectsPosition%s", 
base_params[i].base_path);
 
+               /* Supports transliterated queries */
+               closure = cursor_closure_new (base_params[i].async, base_params[i].dra, "POSIX");
+               cursor_closure_position (closure, 20, 0, TRUE);
+               cursor_closure_move_by (closure,
+                                       E_BOOK_CURSOR_ORIGIN_CURRENT,
+                                       10, /* Count */
+                                       10, /* Expected results */
+                                       11, 2,  6,  3,  8, 1,  5,  4,  7,  15);
+               cursor_closure_position (closure, 20, 10, TRUE);
+               cursor_closure_set_sexp (closure,
+                                        e_book_query_field_test (
+                                               E_CONTACT_EMAIL,
+                                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                                               "几"),
+                                        TRUE);
+
+               /* In POSIX Locale, the 10th contact out of 20 becomes the 2nd out of 3 contacts
+                * which start with the transliterated '几' sound (which transliterates to 'ji').
+                *
+                * Our three matching contacts are:
+                *   sorted-9: jim morrison com
+                *   sorted-4: 警察 brown org (transliterates to "jing cha brown org")
+                *   sorted-5: 救命 brown com (transliterates to "jiu ming brown com")
+                *
+                * All of these emails begin with 'ji'
+                */
+               cursor_closure_position (closure, 3, 2, TRUE);
+
+               cursor_closure_set_sexp (closure,
+                                        e_book_query_field_test (
+                                               E_CONTACT_EMAIL,
+                                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                                               "ji"),
+                                        TRUE);
+
+               /* The '几' sound transliterates to 'ji', so we should have the same results & position.
+                */
+               cursor_closure_position (closure, 3, 2, TRUE);
+               cursor_closure_add (closure, "/EBookClientCursor/SearchExpression/Translit/Email/Prefix/ji%s",
+                                   base_params[i].base_path);
+
                /****************************************************
                 *             Address Book Modifications           *
                 ****************************************************/
diff --git a/tests/libebook/data/vcards/sorted-4.vcf b/tests/libebook/data/vcards/sorted-4.vcf
index 888b89c..e2fb999 100644
--- a/tests/libebook/data/vcards/sorted-4.vcf
+++ b/tests/libebook/data/vcards/sorted-4.vcf
@@ -2,5 +2,5 @@ BEGIN:VCARD
 UID:sorted-4
 N:bat;First Name
 TEL;TYPE=work,pref:+9999999
-EMAIL:big bobby brown org
+EMAIL:警察 brown org
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-5.vcf b/tests/libebook/data/vcards/sorted-5.vcf
index bf6c11a..10360d6 100644
--- a/tests/libebook/data/vcards/sorted-5.vcf
+++ b/tests/libebook/data/vcards/sorted-5.vcf
@@ -2,5 +2,5 @@ BEGIN:VCARD
 UID:sorted-5
 N:bäd;First Name
 TEL;HOME:+6666666
-EMAIL;TYPE=home,work:james brown com
+EMAIL;TYPE=home,work:救命 brown com
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-9.vcf b/tests/libebook/data/vcards/sorted-9.vcf
index 9a825d6..a5ed36b 100644
--- a/tests/libebook/data/vcards/sorted-9.vcf
+++ b/tests/libebook/data/vcards/sorted-9.vcf
@@ -2,5 +2,5 @@ BEGIN:VCARD
 UID:sorted-9
 N:côté;First Name
 TEL;HOME:514-845-8436
-EMAIL;TYPE=home,work:pink pony com
+EMAIL;TYPE=home,work:jim morrison com
 END:VCARD


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