[evolution-data-server/openismus-work-master: 21/74] Fixed test-sqlite-cursor-move-by for new ICU localization



commit ff2fa4833889ee2b7b07cba316b6f1e1804aa37b
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Thu May 2 22:01:39 2013 +0900

    Fixed test-sqlite-cursor-move-by for new ICU localization
    
    Added new sortable vcards and changed the whole sortable data set.
    
    Now there are 4 move-by tests: posix, en_US, fr_CA and de_DE. All
    tests try the default and phonebook collation rules, the de_DE test
    data sorts differently under phonebook sort.
    
    A table was added to data-test-utils.h for reference, showing
    the expected order of sorted contacts in given locales.

 tests/libebook/Makefile.am                         |    9 +
 tests/libebook/data/vcards/sorted-1.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-10.vcf           |    2 +-
 tests/libebook/data/vcards/sorted-12.vcf           |    7 +
 tests/libebook/data/vcards/sorted-13.vcf           |    6 +
 tests/libebook/data/vcards/sorted-14.vcf           |    6 +
 tests/libebook/data/vcards/sorted-15.vcf           |    6 +
 tests/libebook/data/vcards/sorted-16.vcf           |    6 +
 tests/libebook/data/vcards/sorted-17.vcf           |    6 +
 tests/libebook/data/vcards/sorted-18.vcf           |    6 +
 tests/libebook/data/vcards/sorted-19.vcf           |    6 +
 tests/libebook/data/vcards/sorted-2.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-20.vcf           |    6 +
 tests/libebook/data/vcards/sorted-3.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-4.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-5.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-6.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-7.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-8.vcf            |    2 +-
 tests/libebook/data/vcards/sorted-9.vcf            |    2 +-
 tests/libedata-book/Makefile.am                    |   28 +-
 tests/libedata-book/data-test-utils.c              |  320 +++++++++++++-
 tests/libedata-book/data-test-utils.h              |   92 ++++
 .../test-sqlite-cursor-move-by-de-DE.c             |   77 ++++
 .../test-sqlite-cursor-move-by-en-US.c             |   77 ++++
 .../test-sqlite-cursor-move-by-fr-CA.c             |   77 ++++
 .../test-sqlite-cursor-move-by-posix.c             |   78 ++++
 tests/libedata-book/test-sqlite-cursor-move-by.c   |  451 --------------------
 28 files changed, 793 insertions(+), 491 deletions(-)
---
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index 3240b27..d3b47b6 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -73,6 +73,15 @@ EXTRA_DIST = \
        $(srcdir)/data/vcards/sorted-9.vcf      \
        $(srcdir)/data/vcards/sorted-10.vcf     \
        $(srcdir)/data/vcards/sorted-11.vcf     \
+       $(srcdir)/data/vcards/sorted-12.vcf     \
+       $(srcdir)/data/vcards/sorted-13.vcf     \
+       $(srcdir)/data/vcards/sorted-14.vcf     \
+       $(srcdir)/data/vcards/sorted-15.vcf     \
+       $(srcdir)/data/vcards/sorted-16.vcf     \
+       $(srcdir)/data/vcards/sorted-17.vcf     \
+       $(srcdir)/data/vcards/sorted-18.vcf     \
+       $(srcdir)/data/vcards/sorted-19.vcf     \
+       $(srcdir)/data/vcards/sorted-20.vcf     \
        $(srcdir)/data/vcards/custom-1.vcf      \
        $(srcdir)/data/vcards/custom-2.vcf      \
        $(srcdir)/data/vcards/custom-3.vcf      \
diff --git a/tests/libebook/data/vcards/sorted-1.vcf b/tests/libebook/data/vcards/sorted-1.vcf
index eaa7f4b..bd4fdbf 100644
--- a/tests/libebook/data/vcards/sorted-1.vcf
+++ b/tests/libebook/data/vcards/sorted-1.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-1
-N:Jackson;Micheal
+N:bad;First Name
 TEL;HOME:+1-221-5423789
 EMAIL;TYPE=home,work:micheal jackson com
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-10.vcf b/tests/libebook/data/vcards/sorted-10.vcf
index 20042ae..3fbb99b 100644
--- a/tests/libebook/data/vcards/sorted-10.vcf
+++ b/tests/libebook/data/vcards/sorted-10.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-10
-N:J;Mister
+N:C;First Name
 TEL;HOME:+1-221-5423789
 EMAIL;TYPE=home,work:mister jackson com
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-12.vcf b/tests/libebook/data/vcards/sorted-12.vcf
new file mode 100644
index 0000000..b600d03
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-12.vcf
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+UID:sorted-12
+N:coté;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony com
+END:VCARD
+
diff --git a/tests/libebook/data/vcards/sorted-13.vcf b/tests/libebook/data/vcards/sorted-13.vcf
new file mode 100644
index 0000000..a13875c
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-13.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-13
+N:côte;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony org
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-14.vcf b/tests/libebook/data/vcards/sorted-14.vcf
new file mode 100644
index 0000000..cd803b5
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-14.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-14
+N:cote;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony com
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-15.vcf b/tests/libebook/data/vcards/sorted-15.vcf
new file mode 100644
index 0000000..403bc70
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-15.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-15
+N:black-bird;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony org
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-16.vcf b/tests/libebook/data/vcards/sorted-16.vcf
new file mode 100644
index 0000000..6e845db
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-16.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-16
+N:blackbird;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony com
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-17.vcf b/tests/libebook/data/vcards/sorted-17.vcf
new file mode 100644
index 0000000..5f62f4d
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-17.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-17
+N:black-birds;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony com
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-18.vcf b/tests/libebook/data/vcards/sorted-18.vcf
new file mode 100644
index 0000000..c3c3b69
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-18.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-18
+N:blackbirds;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony com
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-19.vcf b/tests/libebook/data/vcards/sorted-19.vcf
new file mode 100644
index 0000000..2971aa2
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-19.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-19
+N:Muffler;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony net
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-2.vcf b/tests/libebook/data/vcards/sorted-2.vcf
index a4ba4b1..9a9b8a2 100644
--- a/tests/libebook/data/vcards/sorted-2.vcf
+++ b/tests/libebook/data/vcards/sorted-2.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-2
-N:Jackson;Janet
+N:Bad;First Name
 TEL;HOME:7654321
 EMAIL:janet jackson com
 EMAIL:janny jackson com
diff --git a/tests/libebook/data/vcards/sorted-20.vcf b/tests/libebook/data/vcards/sorted-20.vcf
new file mode 100644
index 0000000..2d4c8ee
--- /dev/null
+++ b/tests/libebook/data/vcards/sorted-20.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:sorted-20
+N:Müller;First Name
+TEL;HOME:514-845-8436
+EMAIL;TYPE=home,work:pink pony net
+END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-3.vcf b/tests/libebook/data/vcards/sorted-3.vcf
index 74bc136..5f75eeb 100644
--- a/tests/libebook/data/vcards/sorted-3.vcf
+++ b/tests/libebook/data/vcards/sorted-3.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-3
-N:Brown;Bobby
+N:Bat;First Name
 TEL;HOME:+9999999
 EMAIL;TYPE=work:bobby brown org
 EMAIL;TYPE=home,work:bobby brown com
diff --git a/tests/libebook/data/vcards/sorted-4.vcf b/tests/libebook/data/vcards/sorted-4.vcf
index 289ac33..888b89c 100644
--- a/tests/libebook/data/vcards/sorted-4.vcf
+++ b/tests/libebook/data/vcards/sorted-4.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-4
-N:Brown;Big Bobby
+N:bat;First Name
 TEL;TYPE=work,pref:+9999999
 EMAIL:big bobby brown org
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-5.vcf b/tests/libebook/data/vcards/sorted-5.vcf
index 7798496..bf6c11a 100644
--- a/tests/libebook/data/vcards/sorted-5.vcf
+++ b/tests/libebook/data/vcards/sorted-5.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-5
-N:Brown;James
+N:bäd;First Name
 TEL;HOME:+6666666
 EMAIL;TYPE=home,work:james brown com
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-6.vcf b/tests/libebook/data/vcards/sorted-6.vcf
index fbcdfe9..2af7b7d 100644
--- a/tests/libebook/data/vcards/sorted-6.vcf
+++ b/tests/libebook/data/vcards/sorted-6.vcf
@@ -1,5 +1,5 @@
 BEGIN:VCARD
 UID:sorted-6
-N:%Strange Name;Mister
+N:Bäd;First Name
 TEL;HOME:ask Jenny for Lisa's number
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-7.vcf b/tests/libebook/data/vcards/sorted-7.vcf
index 861cd88..4a9c3e6 100644
--- a/tests/libebook/data/vcards/sorted-7.vcf
+++ b/tests/libebook/data/vcards/sorted-7.vcf
@@ -1,5 +1,5 @@
 BEGIN:VCARD
 UID:sorted-7
-N:Goose;Purple
+N:bät;First Name
 TEL;HOME:+49-89-7888 99
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-8.vcf b/tests/libebook/data/vcards/sorted-8.vcf
index ba8b06e..456181e 100644
--- a/tests/libebook/data/vcards/sorted-8.vcf
+++ b/tests/libebook/data/vcards/sorted-8.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-8
-N:Pony;Purple
+N:Bät;First Name
 TEL;HOME:+31-221-5423789
 EMAIL;TYPE=home,work:purple pony com
 END:VCARD
diff --git a/tests/libebook/data/vcards/sorted-9.vcf b/tests/libebook/data/vcards/sorted-9.vcf
index 685420f..9a825d6 100644
--- a/tests/libebook/data/vcards/sorted-9.vcf
+++ b/tests/libebook/data/vcards/sorted-9.vcf
@@ -1,6 +1,6 @@
 BEGIN:VCARD
 UID:sorted-9
-N:Pony;Pink
+N:côté;First Name
 TEL;HOME:514-845-8436
 EMAIL;TYPE=home,work:pink pony com
 END:VCARD
diff --git a/tests/libedata-book/Makefile.am b/tests/libedata-book/Makefile.am
index c579dd3..aeeb84f 100644
--- a/tests/libedata-book/Makefile.am
+++ b/tests/libedata-book/Makefile.am
@@ -43,19 +43,21 @@ libdata_test_utils_la_LIBADD =                              \
 #
 # This is because each migrated test changes the
 # locale and reloads the same addressbook of the previous test. 
-TESTS =                                        \
-       test-sqlite-get-contact         \
-       test-sqlite-create-cursor       \
-       test-sqlite-cursor-move-by      \
-       test-sqlite-cursor-set-target   \
-       test-sqlite-cursor-calculate    \
-       test-sqlite-cursor-set-sexp     \
+TESTS =                                                \
+       test-sqlite-get-contact                 \
+       test-sqlite-create-cursor               \
+       test-sqlite-cursor-move-by-posix        \
+       test-sqlite-cursor-move-by-en-US        \
+       test-sqlite-cursor-move-by-fr-CA        \
+       test-sqlite-cursor-move-by-de-DE        \
+       test-sqlite-cursor-set-target           \
+       test-sqlite-cursor-calculate            \
+       test-sqlite-cursor-set-sexp             \
        test-sqlite-cursor-posix-initial        \
        test-sqlite-cursor-en-US-migrated       \
        test-sqlite-cursor-posix-migrated
 
 
-
 noinst_PROGRAMS = $(TESTS)
 
 TEST_CPPFLAGS =                                                        \
@@ -74,8 +76,14 @@ test_sqlite_get_contact_LDADD=$(TEST_LIBS)
 test_sqlite_get_contact_CPPFLAGS=$(TEST_CPPFLAGS)
 test_sqlite_create_cursor_LDADD=$(TEST_LIBS)
 test_sqlite_create_cursor_CPPFLAGS=$(TEST_CPPFLAGS)
-test_sqlite_cursor_move_by_LDADD=$(TEST_LIBS)
-test_sqlite_cursor_move_by_CPPFLAGS=$(TEST_CPPFLAGS)
+test_sqlite_cursor_move_by_posix_LDADD=$(TEST_LIBS)
+test_sqlite_cursor_move_by_posix_CPPFLAGS=$(TEST_CPPFLAGS)
+test_sqlite_cursor_move_by_en_US_LDADD=$(TEST_LIBS)
+test_sqlite_cursor_move_by_en_US_CPPFLAGS=$(TEST_CPPFLAGS)
+test_sqlite_cursor_move_by_fr_CA_LDADD=$(TEST_LIBS)
+test_sqlite_cursor_move_by_fr_CA_CPPFLAGS=$(TEST_CPPFLAGS)
+test_sqlite_cursor_move_by_de_DE_LDADD=$(TEST_LIBS)
+test_sqlite_cursor_move_by_de_DE_CPPFLAGS=$(TEST_CPPFLAGS)
 test_sqlite_cursor_set_target_LDADD=$(TEST_LIBS)
 test_sqlite_cursor_set_target_CPPFLAGS=$(TEST_CPPFLAGS)
 test_sqlite_cursor_calculate_LDADD=$(TEST_LIBS)
diff --git a/tests/libedata-book/data-test-utils.c b/tests/libedata-book/data-test-utils.c
index ccaee22..7267112 100644
--- a/tests/libedata-book/data-test-utils.c
+++ b/tests/libedata-book/data-test-utils.c
@@ -197,6 +197,108 @@ e_sqlitedb_fixture_teardown (ESqliteDBFixture *fixture,
        e_test_server_utils_teardown ((ETestServerFixture *)fixture, user_data);
 }
 
+void
+e_sqlitedb_cursor_fixture_setup_book (ESource            *scratch,
+                                     ETestServerClosure *closure)
+{
+       ESourceBackendSummarySetup *setup;
+       EbSdbCursorClosure *data = (EbSdbCursorClosure *)closure;
+
+       g_type_class_unref (g_type_class_ref (E_TYPE_SOURCE_BACKEND_SUMMARY_SETUP));
+       setup = e_source_get_extension (scratch, E_SOURCE_EXTENSION_BACKEND_SUMMARY_SETUP);
+       e_source_backend_summary_setup_set_summary_fields (setup,
+                                                          E_CONTACT_FAMILY_NAME,
+                                                          E_CONTACT_GIVEN_NAME,
+                                                          E_CONTACT_EMAIL,
+                                                          0);
+       e_source_backend_summary_setup_set_indexed_fields (setup,
+                                                          E_CONTACT_FAMILY_NAME, E_BOOK_INDEX_PREFIX,
+                                                          E_CONTACT_GIVEN_NAME, E_BOOK_INDEX_PREFIX,
+                                                          E_CONTACT_EMAIL, E_BOOK_INDEX_PREFIX,
+                                                          0);
+
+       if (data->phonebook_order)
+               e_source_backend_summary_setup_set_collations (setup,
+                                                              E_CONTACT_FAMILY_NAME, "phonebook",
+                                                              E_CONTACT_GIVEN_NAME, "phonebook",
+                                                              0);
+}
+
+void
+e_sqlitedb_cursor_fixture_setup (EbSdbCursorFixture *fixture,
+                                gconstpointer       user_data)
+{
+       EContactField sort_fields[] = { E_CONTACT_FAMILY_NAME, E_CONTACT_GIVEN_NAME };
+       EBookSortType sort_types[] = { E_BOOK_SORT_ASCENDING, E_BOOK_SORT_ASCENDING };
+       EBookClient *book_client;
+       GSList *contacts = NULL;
+       GError *error = NULL;
+       gint i;
+       gchar *sexp = NULL;
+
+       e_sqlitedb_fixture_setup ((ESqliteDBFixture *)fixture, user_data);
+
+       book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
+
+       for (i = 0; i < N_SORTED_CONTACTS; i++) {
+               gchar *case_name = g_strdup_printf ("sorted-%d", i + 1);
+               gchar *vcard;
+               EContact *contact;
+
+               vcard    = new_vcard_from_test_case (case_name);
+               contact  = e_contact_new_from_vcard (vcard);
+               contacts = g_slist_prepend (contacts, contact);
+               g_free (vcard);
+               g_free (case_name);
+
+               fixture->contacts[i] = contact;
+       }
+
+       if (!e_book_client_add_contacts_sync (book_client, contacts, NULL, NULL, &error))
+               g_error ("Failed to add test contacts");
+
+       g_slist_free (contacts);
+
+       /* Allow a surrounding fixture setup to add a query here */
+       if (fixture->query) {
+               sexp = e_book_query_to_string (fixture->query);
+               e_book_query_unref (fixture->query);
+               fixture->query = NULL;
+       }
+
+       fixture->cursor = e_book_backend_sqlitedb_cursor_new (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                             SQLITEDB_FOLDER_ID,
+                                                             sexp, sort_fields, sort_types, 2, &error);
+
+
+       g_free (sexp);
+
+       g_assert (fixture->cursor != NULL);
+}
+
+void
+e_sqlitedb_cursor_fixture_filtered_setup (EbSdbCursorFixture *fixture,
+                                         gconstpointer  user_data)
+{
+       fixture->query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_ENDS_WITH, ".com");
+
+       e_sqlitedb_cursor_fixture_setup (fixture, user_data);
+}
+
+void
+e_sqlitedb_cursor_fixture_teardown (EbSdbCursorFixture *fixture,
+                                   gconstpointer       user_data)
+{
+       gint i;
+
+       for (i = 0; i < N_SORTED_CONTACTS; i++) {
+               if (fixture->contacts[i])
+                       g_object_unref (fixture->contacts[i]);
+       }
+
+       e_book_backend_sqlitedb_cursor_free (((ESqliteDBFixture *) fixture)->ebsdb, fixture->cursor);
+       e_sqlitedb_fixture_teardown ((ESqliteDBFixture *)fixture, user_data);
+}
 
 static gint
 find_contact_data (EbSdbSearchData *data,
@@ -206,12 +308,37 @@ find_contact_data (EbSdbSearchData *data,
 }
 
 void
+assert_contacts_order_slist (GSList      *results,
+                            GSList      *uids)
+{
+       gint position = -1;
+       GSList *link, *l;
+
+       /* Assert that all passed UIDs are found in the
+        * results, and that those UIDs are in the
+        * specified order.
+        */
+       for (l = uids; l; l = l->next) {
+               const gchar *uid = l->data;
+               gint new_position;
+
+               link = g_slist_find_custom (results, uid, (GCompareFunc)find_contact_data);
+               if (!link)
+                       g_error ("Specified uid '%s' was not found in results", uid);
+
+               new_position = g_slist_position (results, link);
+               g_assert_cmpint (new_position, >, position);
+               position = new_position;
+       }
+
+}
+
+void
 assert_contacts_order (GSList      *results,
                       const gchar *first_uid,
                       ...)
 {
-       GSList *uids = NULL, *link, *l;
-       gint position = -1;
+       GSList *uids = NULL;
        gchar *uid;
        va_list args;
 
@@ -227,24 +354,7 @@ assert_contacts_order (GSList      *results,
        }
        va_end (args);
 
-       /* Assert that all passed UIDs are found in the
-        * results, and that those UIDs are in the
-        * specified order.
-        */
-       for (l = uids; l; l = l->next) {
-               gint new_position;
-
-               uid = l->data;
-
-               link = g_slist_find_custom (results, uid, (GCompareFunc)find_contact_data);
-               if (!link)
-                       g_error ("Specified uid was not found in results");
-
-               new_position = g_slist_position (results, link);
-               g_assert_cmpint (new_position, >, position);
-               position = new_position;
-       }
-
+       assert_contacts_order_slist (results, uids);
        g_slist_free (uids);
 }
 
@@ -266,3 +376,173 @@ print_results (GSList      *results)
 
        g_print ("\nRESULT LIST_FINISHED\n");
 }
+
+/********************************************
+ *           Move By Test Helpers
+ ********************************************/
+#define DEBUG_FIXTURE        0
+
+static MoveByData *
+move_by_test_new_internal (const gchar *test_path,
+                          gboolean     phonebook_order,
+                          gsize        struct_size)
+{
+       MoveByData *data;
+
+       data = g_slice_alloc0 (struct_size);
+       data->parent.parent.type = E_TEST_SERVER_ADDRESS_BOOK;
+       data->parent.parent.customize = e_sqlitedb_cursor_fixture_setup_book;
+       data->parent.phonebook_order = phonebook_order;
+       data->path = g_strdup (test_path);
+       data->struct_size = struct_size;
+
+       return data;
+}
+
+static void
+move_by_test_free (MoveByData *data)
+{
+       g_free (data->path);
+       g_slice_free1 (data->struct_size, data);
+}
+
+MoveByData *
+move_by_test_new (const gchar *test_path,
+                 gboolean     phonebook_order)
+{
+       return move_by_test_new_internal (test_path,
+                                         phonebook_order,
+                                         sizeof (MoveByData));
+}
+
+static void
+test_cursor_move_teardown (EbSdbCursorFixture *fixture,
+                          gconstpointer  user_data)
+{
+       MoveByData *data = (MoveByData *)user_data;
+
+       e_sqlitedb_cursor_fixture_teardown (fixture, user_data);
+
+       move_by_test_free (data);
+}
+
+static void
+test_move_by (EbSdbCursorFixture *fixture,
+             gconstpointer  user_data)
+{
+       MoveByData *data = (MoveByData *)user_data;
+       GSList *results;
+       GError *error = NULL;
+       gint i, j;
+
+       for (i = 0; i < MAX_MOVE_BY_COUNTS && data->counts[i] != 0; i++) {
+               GSList *uids = NULL;
+
+               results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                                 fixture->cursor, data->counts[i], &error);
+               if (error)
+                       g_error ("Error fetching cursor results: %s", error->message);
+
+               print_results (results);
+
+               /* Assert the exact amount of requested results */
+               g_assert_cmpint (g_slist_length (results), ==, ABS (data->counts[i]));
+
+#if DEBUG_FIXTURE
+               g_print ("%s: Constructing expected result list for a fetch of %d: ",
+                        data->path, data->counts[i]);
+#endif
+
+               for (j = 0; j < ABS (data->counts[i]); j++) {
+                       gint index = data->expected[i][j];
+                       gchar *uid;
+
+                       uid = (gchar *)e_contact_get_const (fixture->contacts[index], E_CONTACT_UID);
+                       uids = g_slist_append (uids, uid);
+
+#if DEBUG_FIXTURE
+                       g_print ("%s ", uid);
+#endif
+
+               }
+#if DEBUG_FIXTURE
+               g_print ("\n");
+#endif
+
+               assert_contacts_order_slist (results, uids);
+               g_slist_free (uids);
+
+               g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
+               g_slist_free (results);
+       }
+}
+
+static void
+move_by_test_add_assertion_va_list (MoveByData *data,
+                                   gint        count,
+                                   va_list     args)
+{
+       gint i, j;
+       gint expected;
+
+       for (i = 0; i < MAX_MOVE_BY_COUNTS; i++) {
+
+               /* Find the next available test slot */
+               if (data->counts[i] == 0) {
+                       data->counts[i] = count;
+
+#if DEBUG_FIXTURE
+                       g_print ("Adding assertion to test %d: %s\n", i + 1, data->path);
+                       g_print ("  Test will move by %d and expect: ", count);
+#endif
+                       for (j = 0; j < ABS (count); j++) {
+                               expected = va_arg (args, gint);
+
+#if DEBUG_FIXTURE
+                               g_print ("%d ", expected);
+#endif
+                               data->expected[i][j] = expected - 1;
+                       }
+#if DEBUG_FIXTURE
+                       g_print ("\n");
+#endif
+
+                       break;
+               }
+       }
+
+       g_assert (i < MAX_MOVE_BY_COUNTS);
+}
+
+/* A positive of negative 'count' value
+ * followed by ABS (count) UID indexes.
+ *
+ * The indexes start at 1 so that they
+ * are easier to match up with the chart
+ * in data-test-utils.h
+ */
+void
+move_by_test_add_assertion (MoveByData *data,
+                           gint        count,
+                           ...)
+{
+
+       va_list args;
+
+       va_start (args, count);
+       move_by_test_add_assertion_va_list (data, count, args);
+       va_end (args);
+}
+
+void
+move_by_test_add (MoveByData  *data,
+                 gboolean     filtered)
+{
+       g_test_add (data->path, EbSdbCursorFixture, data,
+                   filtered ?
+                   e_sqlitedb_cursor_fixture_filtered_setup :
+                   e_sqlitedb_cursor_fixture_setup,
+                   test_move_by,
+                   test_cursor_move_teardown);
+}
+
diff --git a/tests/libedata-book/data-test-utils.h b/tests/libedata-book/data-test-utils.h
index f1b3d97..b8474a2 100644
--- a/tests/libedata-book/data-test-utils.h
+++ b/tests/libedata-book/data-test-utils.h
@@ -26,7 +26,49 @@
 #include <libedata-book/libedata-book.h>
 #include "e-test-server-utils.h"
 
+
+/* This legend shows the add order, and various sort order of the sorted
+ * vcards. The UIDs of these contacts are formed as 'sorted-1', 'sorted-2' etc
+ * and the numbering of the contacts is according to the 'N' column in the
+ * following legend.
+ *
+ * The Email column indicates whether the contact has a .com email address
+ * (in order to test filtered cursor results) and corresponds to the natural
+ * order in the 'N' column.
+ *
+ * +-----------------------------------------------------------------------------------------------+
+ * | N   | Email | Last Name   | en_US_POSIX    | en_US / de_DE  | fr_CA          | de_DE          |
+ * |     |       |             |                |                |                | (phonebook)    |
+ * +-----------------------------------------------------------------------------------------------+
+ * | 1   | Yes   | bad         |             11 |             11 |             11 |             11 |
+ * | 2   | Yes   | Bad         | Bad         2  | bad         1  | bad         1  | bad         1  |
+ * | 3   | Yes   | Bat         | Bäd         6  | Bad         2  | Bad         2  | Bad         2  |
+ * | 4   | No    | bat         | Bat         3  | bäd         5  | bäd         5  | bäd         5  |
+ * | 5   | Yes   | bäd         | Bät         8  | Bäd         6  | Bäd         6  | Bäd         6  |
+ * | 6   | No    | Bäd         | C           10 | bat         4  | bat         4  | bät         7  |
+ * | 7   | No    | bät         | Muffler     19 | Bat         3  | Bat         3  | Bät         8  |
+ * | 8   | Yes   | Bät         | Müller      20 | bät         7  | bät         7  | bat         4  |
+ * | 9   | Yes   | côté        | bad         1  | Bät         8  | Bät         8  | Bat         3  |
+ * | 10  | Yes   | C           | bäd         5  | black-bird  15 | black-bird  15 | black-bird  15 |
+ * | 11  | Yes   |             | bat         4  | black-birds 17 | black-birds 17 | black-birds 17 |
+ * | 12  | Yes   | coté        | bät         7  | blackbird   16 | blackbird   16 | blackbird   16 |
+ * | 13  | No    | côte        | black-bird  15 | blackbirds  18 | blackbirds  18 | blackbirds  18 |
+ * | 14  | Yes   | cote        | black-birds 17 | C           10 | C           10 | C           10 |
+ * | 15  | No    | black-bird  | blackbird   16 | cote        14 | cote        14 | cote        14 |
+ * | 16  | Yes   | blackbird   | blackbirds  18 | coté        12 | côte        13 | coté        12 | 
+ * | 17  | Yes   | black-birds | cote        14 | côte        13 | coté        12 | côte        13 | 
+ * | 18  | Yes   | blackbirds  | coté        12 | côté        9  | côté        9  | côté        9  | 
+ * | 19  | No    | Muffler     | côte        13 | Muffler     19 | Muffler     19 | Müller      20 | 
+ * | 20  | No    | Müller      | côté        9  | Müller      20 | Müller      20 | Muffler     19 |
+ * +-----------------------------------------------------------------------------------------------+
+ *
+ * See this ICU demo to check additional sort ordering by ICU in various locales:
+ *     http://demo.icu-project.org/icu-bin/locexp?_=en_US&d_=en&x=col
+ */
+
 #define SQLITEDB_FOLDER_ID   "folder_id"
+#define N_SORTED_CONTACTS    20
+#define MAX_MOVE_BY_COUNTS   5
 
 typedef struct {
        ETestServerFixture parent_fixture;
@@ -34,11 +76,50 @@ typedef struct {
        EBookBackendSqliteDB *ebsdb;
 } ESqliteDBFixture;
 
+typedef struct {
+       ESqliteDBFixture parent_fixture;
+
+       EbSdbCursor     *cursor;
+       EContact        *contacts[N_SORTED_CONTACTS];
+       EBookQuery      *query;
+} EbSdbCursorFixture;
+
+typedef struct {
+       ETestServerClosure parent;
+
+       gboolean phonebook_order;
+} EbSdbCursorClosure;
+
+typedef struct {
+       EbSdbCursorClosure parent;
+       gchar *path;
+
+       /* array of counts to move by, terminated with 0 or MAX_COUNTS */
+       gint counts[MAX_MOVE_BY_COUNTS];
+
+       /* For each move_by() command, an array of 'ABS (counts[i])' expected contacts */
+       gint expected[MAX_MOVE_BY_COUNTS][N_SORTED_CONTACTS];
+
+       /* Private detail */
+       gsize struct_size;
+} MoveByData;
+
 void     e_sqlitedb_fixture_setup          (ESqliteDBFixture *fixture,
                                            gconstpointer     user_data);
 void     e_sqlitedb_fixture_teardown       (ESqliteDBFixture *fixture,
                                            gconstpointer     user_data);
 
+void     e_sqlitedb_cursor_fixture_setup_book (ESource            *scratch,
+                                              ETestServerClosure *closure);
+void     e_sqlitedb_cursor_fixture_setup    (EbSdbCursorFixture *fixture,
+                                            gconstpointer       user_data);
+void     e_sqlitedb_cursor_fixture_teardown (EbSdbCursorFixture *fixture,
+                                            gconstpointer       user_data);
+
+/* Filters contacts with E_CONTACT_EMAIL ending with '.com' */
+void     e_sqlitedb_cursor_fixture_filtered_setup (EbSdbCursorFixture *fixture,
+                                                  gconstpointer  user_data);
+
 
 gchar    *new_vcard_from_test_case         (const gchar *case_name);
 EContact *new_contact_from_test_case       (const gchar *case_name);
@@ -47,10 +128,21 @@ gboolean add_contact_from_test_case_verify (EBookClient *book_client,
                                            const gchar *case_name,
                                            EContact   **contact);
 
+void     assert_contacts_order_slist       (GSList      *results,
+                                           GSList      *uids);
 void     assert_contacts_order             (GSList      *results,
                                            const gchar *first_uid,
                                            ...) G_GNUC_NULL_TERMINATED;
 
 void     print_results                     (GSList      *results);
 
+/*  MoveBy test helpers */
+void        move_by_test_add_assertion     (MoveByData  *data,
+                                           gint         count,
+                                           ...);
+MoveByData *move_by_test_new               (const gchar *test_path,
+                                           gboolean     phonebook_order);
+void        move_by_test_add               (MoveByData  *data,
+                                           gboolean     filtered);
+
 #endif /* DATA_TEST_UTILS_H */
diff --git a/tests/libedata-book/test-sqlite-cursor-move-by-de-DE.c 
b/tests/libedata-book/test-sqlite-cursor-move-by-de-DE.c
new file mode 100644
index 0000000..c3c2a18
--- /dev/null
+++ b/tests/libedata-book/test-sqlite-cursor-move-by-de-DE.c
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <locale.h>
+#include <libebook/libebook.h>
+
+#include "data-test-utils.h"
+
+gint
+main (gint argc,
+      gchar **argv)
+{
+       MoveByData *data;
+
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+       g_type_init ();
+#endif
+       g_test_init (&argc, &argv, NULL);
+
+       /* Ensure that the client and server get the same locale */
+       g_assert (g_setenv ("EDS_COLLATE", "de_DE.UTF-8", TRUE));
+
+       /* Try them all once in the normal base locale */
+       data = move_by_test_new ("/EbSdbCursor/de_DE/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 4, 3, 7, 8, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE/Move/ForwardOnNameless", FALSE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 20, 19, 9, 13, 12);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 8, 7);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE/Filtered/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 3);
+       move_by_test_add_assertion (data, 8, 8, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE/Filtered/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 8, 3, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+
+       /* Try them all again with collation = phonebook */
+       data = move_by_test_new ("/EbSdbCursor/de_DE collation=phonebook/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 7, 8, 4, 3, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE collation=phonebook/Move/ForwardOnNameless", TRUE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE collation=phonebook/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 19, 20, 9, 13, 12);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 3, 4);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE collation=phonebook/Filtered/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 8);
+       move_by_test_add_assertion (data, 8, 3, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/de_DE collation=phonebook/Filtered/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 3, 8, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+       return e_test_server_utils_run ();
+}
diff --git a/tests/libedata-book/test-sqlite-cursor-move-by-en-US.c 
b/tests/libedata-book/test-sqlite-cursor-move-by-en-US.c
new file mode 100644
index 0000000..697bf7d
--- /dev/null
+++ b/tests/libedata-book/test-sqlite-cursor-move-by-en-US.c
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <locale.h>
+#include <libebook/libebook.h>
+
+#include "data-test-utils.h"
+
+gint
+main (gint argc,
+      gchar **argv)
+{
+       MoveByData *data;
+
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+       g_type_init ();
+#endif
+       g_test_init (&argc, &argv, NULL);
+
+       /* Ensure that the client and server get the same locale */
+       g_assert (g_setenv ("EDS_COLLATE", "en_US.UTF-8", TRUE));
+
+       /* Try them all once in the normal base locale */
+       data = move_by_test_new ("/EbSdbCursor/en_US/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 4, 3, 7, 8, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US/Move/ForwardOnNameless", FALSE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 20, 19, 9, 13, 12);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 8, 7);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US/Filtered/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 3);
+       move_by_test_add_assertion (data, 8, 8, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US/Filtered/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 8, 3, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+
+       /* Try them all again with collation = phonebook */
+       data = move_by_test_new ("/EbSdbCursor/en_US collation=phonebook/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 4, 3, 7, 8, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US collation=phonebook/Move/ForwardOnNameless", TRUE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US collation=phonebook/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 20, 19, 9, 13, 12);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 8, 7);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US collation=phonebook/Filtered/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 3);
+       move_by_test_add_assertion (data, 8, 8, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/en_US collation=phonebook/Filtered/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 8, 3, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+       return e_test_server_utils_run ();
+}
diff --git a/tests/libedata-book/test-sqlite-cursor-move-by-fr-CA.c 
b/tests/libedata-book/test-sqlite-cursor-move-by-fr-CA.c
new file mode 100644
index 0000000..654fba8
--- /dev/null
+++ b/tests/libedata-book/test-sqlite-cursor-move-by-fr-CA.c
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <locale.h>
+#include <libebook/libebook.h>
+
+#include "data-test-utils.h"
+
+gint
+main (gint argc,
+      gchar **argv)
+{
+       MoveByData *data;
+
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+       g_type_init ();
+#endif
+       g_test_init (&argc, &argv, NULL);
+
+       /* Ensure that the client and server get the same locale */
+       g_assert (g_setenv ("EDS_COLLATE", "fr_CA.UTF-8", TRUE));
+
+       /* Try them all once in the normal base locale */
+       data = move_by_test_new ("/EbSdbCursor/fr_CA/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 4, 3, 7, 8, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA/Move/ForwardOnNameless", FALSE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 20, 19, 9, 12, 13);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 8, 7);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA/Filtered/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 3);
+       move_by_test_add_assertion (data, 8, 8, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA/Filtered/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 8, 3, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+
+       /* Try them all again with collation = phonebook */
+       data = move_by_test_new ("/EbSdbCursor/fr_CA collation=phonebook/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 6);
+       move_by_test_add_assertion (data, 6, 4, 3, 7, 8, 15, 17);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA collation=phonebook/Move/ForwardOnNameless", TRUE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 1, 2, 5);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA collation=phonebook/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 20, 19, 9, 12, 13);
+       move_by_test_add_assertion (data, -8, 14, 10, 18, 16, 17, 15, 8, 7);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA collation=phonebook/Filtered/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 1, 2, 5, 3);
+       move_by_test_add_assertion (data, 8, 8, 17, 16, 18, 10, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/fr_CA collation=phonebook/Filtered/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 10, 18);
+       move_by_test_add_assertion (data, -8, 16, 17, 8, 3, 5, 2, 1, 11);
+       move_by_test_add (data, TRUE);
+
+       return e_test_server_utils_run ();
+}
diff --git a/tests/libedata-book/test-sqlite-cursor-move-by-posix.c 
b/tests/libedata-book/test-sqlite-cursor-move-by-posix.c
new file mode 100644
index 0000000..5b19644
--- /dev/null
+++ b/tests/libedata-book/test-sqlite-cursor-move-by-posix.c
@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <locale.h>
+#include <libebook/libebook.h>
+
+#include "data-test-utils.h"
+
+gint
+main (gint argc,
+      gchar **argv)
+{
+       MoveByData *data;
+
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+       g_type_init ();
+#endif
+       g_test_init (&argc, &argv, NULL);
+
+       /* Ensure that the client and server get the same locale */
+       g_assert (g_setenv ("EDS_COLLATE", "POSIX", TRUE));
+
+       /* Try them all once in the normal base locale */
+       data = move_by_test_new ("/EbSdbCursor/POSIX/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 2, 6, 3, 8);
+       move_by_test_add_assertion (data, 6, 10, 19, 20, 1, 5, 4);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX/Move/ForwardOnNameless", FALSE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 2, 6, 3);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 9, 13, 12, 14, 18);
+       move_by_test_add_assertion (data, -12, 16, 17, 15, 7, 4, 5, 1, 20, 19, 10, 8, 3);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX/Filtered/Move/Forward", FALSE);
+       move_by_test_add_assertion (data, 5, 11, 2, 3, 8, 10);
+       move_by_test_add_assertion (data, 8, 1, 5, 17, 16, 18, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX/Filtered/Move/Backwards", FALSE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 18, 16);
+       move_by_test_add_assertion (data, -8, 17, 5, 1, 10, 8, 3, 2, 11);
+       move_by_test_add (data, TRUE);
+
+
+       /* Try them all again with collation = phonebook */
+       data = move_by_test_new ("/EbSdbCursor/POSIX collation=phonebook/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 2, 6, 3, 8);
+       move_by_test_add_assertion (data, 6, 10, 19, 20, 1, 5, 4);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX collation=phonebook/Move/ForwardOnNameless", TRUE);
+       move_by_test_add_assertion (data, 1, 11);
+       move_by_test_add_assertion (data, 3, 2, 6, 3);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX collation=phonebook/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 9, 13, 12, 14, 18);
+       move_by_test_add_assertion (data, -12, 16, 17, 15, 7, 4, 5, 1, 20, 19, 10, 8, 3);
+       move_by_test_add (data, FALSE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX collation=phonebook/Filtered/Move/Forward", TRUE);
+       move_by_test_add_assertion (data, 5, 11, 2, 3, 8, 10);
+       move_by_test_add_assertion (data, 8, 1, 5, 17, 16, 18, 14, 12, 9);
+       move_by_test_add (data, TRUE);
+
+       data = move_by_test_new ("/EbSdbCursor/POSIX collation=phonebook/Filtered/Move/Backwards", TRUE);
+       move_by_test_add_assertion (data, -5, 9, 12, 14, 18, 16);
+       move_by_test_add_assertion (data, -8, 17, 5, 1, 10, 8, 3, 2, 11);
+       move_by_test_add (data, TRUE);
+
+
+       return e_test_server_utils_run ();
+}



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