[evolution-data-server/openismus-work-3-8: 64/116] Fixed cursor tests to use the new _move_by() API.



commit bc7251b63a12ed9b833c3d70d50cab6a20335ecc
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Mon Jun 17 15:42:34 2013 +0900

    Fixed cursor tests to use the new _move_by() API.

 tests/libedata-book/data-test-utils.c              |   74 +++++++---
 tests/libedata-book/data-test-utils.h              |    7 +
 tests/libedata-book/test-sqlite-cursor-calculate.c |  157 +++++++++-----------
 tests/libedata-book/test-sqlite-cursor-set-sexp.c  |   11 +-
 .../libedata-book/test-sqlite-cursor-set-target.c  |   47 +++----
 5 files changed, 157 insertions(+), 139 deletions(-)
---
diff --git a/tests/libedata-book/data-test-utils.c b/tests/libedata-book/data-test-utils.c
index ea49211..c5f4c44 100644
--- a/tests/libedata-book/data-test-utils.c
+++ b/tests/libedata-book/data-test-utils.c
@@ -599,54 +599,88 @@ test_move_by (EbSdbCursorFixture *fixture,
              gconstpointer  user_data)
 {
        MoveByData *data = (MoveByData *)user_data;
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint i;
+       gint expected_position = 0, position;
+       gint total;
+
+       total = data->filtered ? N_FILTERED_CONTACTS : N_SORTED_CONTACTS;
 
        for (i = 0; i < MAX_MOVE_BY_COUNTS && data->counts[i] != 0; i++) {
 
+               /* From the 0 position, a negative move starts from the end */
+               if (expected_position == 0 && data->counts[i] < 0)
+                       expected_position = (total + 1) - ABS (data->counts[i]);
+               else
+                       expected_position += data->counts[i];
+
+               if (expected_position > total || expected_position < 1)
+                       expected_position = 0;
+
                /* Try normal order */
-               results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                                 fixture->cursor,
-                                                                 EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                                 data->counts[i], &error);
-               if (error)
+               if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                            fixture->cursor,
+                                                            EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                            data->counts[i],
+                                                            &results, &error))
                        g_error ("Error fetching cursor results: %s", error->message);
 
                print_results (results);
                assert_move_by (fixture, data, i, results);
-
                g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
                g_slist_free (results);
+               results = NULL;
+
+               if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                              fixture->cursor, NULL, &position, &error))
+                       g_error ("Error calculating cursor: %s", error->message);
+               g_assert_cmpint (expected_position, ==, position);
 
                /* Try repeat last query */
-               results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                                 fixture->cursor,
-                                                                 EBSDB_CURSOR_ORIGIN_PREVIOUS,
-                                                                 data->counts[i], &error);
-               if (error)
+               if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                            fixture->cursor,
+                                                            EBSDB_CURSOR_ORIGIN_PREVIOUS,
+                                                            data->counts[i],
+                                                            &results, &error))
                        g_error ("Error fetching cursor results: %s", error->message);
 
                print_results (results);
                assert_move_by (fixture, data, i, results);
-
                g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
                g_slist_free (results);
+               results = NULL;
+
+               if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                              fixture->cursor, NULL, &position, &error))
+                       g_error ("Error calculating cursor: %s", error->message);
+               g_assert_cmpint (expected_position, ==, position);
        }
 
        /* One more, test reset API, the first batch from the beginning */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_RESET,
-                                                         data->counts[0], &error);
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_RESET,
+                                                    data->counts[0],
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        print_results (results);
        assert_move_by (fixture, data, 0, results);
-
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
+
+       /* From the 0 position, a negative move starts from the end */
+       if (data->counts[0] < 0)
+               expected_position = (total + 1) - ABS (data->counts[0]);
+       else
+               expected_position = data->counts[0];
+
+       if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                      fixture->cursor, NULL, &position, &error))
+               g_error ("Error calculating cursor: %s", error->message);
+       g_assert_cmpint (expected_position, ==, position);
 }
 
 static void
@@ -710,6 +744,8 @@ void
 move_by_test_add (MoveByData  *data,
                  gboolean     filtered)
 {
+       data->filtered = filtered;
+
        g_test_add (data->path, EbSdbCursorFixture, data,
                    filtered ?
                    e_sqlitedb_cursor_fixture_filtered_setup :
diff --git a/tests/libedata-book/data-test-utils.h b/tests/libedata-book/data-test-utils.h
index 6e86dfb..58d865f 100644
--- a/tests/libedata-book/data-test-utils.h
+++ b/tests/libedata-book/data-test-utils.h
@@ -70,6 +70,10 @@
 #define N_SORTED_CONTACTS    20
 #define MAX_MOVE_BY_COUNTS   5
 
+/* 13 contacts in the test data have an email address ending with ".com" */
+#define N_FILTERED_CONTACTS  13
+
+
 typedef struct {
        ETestServerFixture parent_fixture;
 
@@ -104,6 +108,9 @@ typedef struct {
        /* For each move_by() command, an array of 'ABS (counts[i])' expected contacts */
        gint expected[MAX_MOVE_BY_COUNTS][N_SORTED_CONTACTS];
 
+       /* Whether this is a filtered test */
+       gboolean filtered;
+
        /* Private detail */
        gsize struct_size;
 } MoveByData;
diff --git a/tests/libedata-book/test-sqlite-cursor-calculate.c 
b/tests/libedata-book/test-sqlite-cursor-calculate.c
index c60e726..fc9a99f 100644
--- a/tests/libedata-book/test-sqlite-cursor-calculate.c
+++ b/tests/libedata-book/test-sqlite-cursor-calculate.c
@@ -37,17 +37,16 @@ static void
 test_cursor_calculate_move_forward (EbSdbCursorFixture *fixture,
                                    gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        /* Assert the first 5 contacts in en_US order */
@@ -76,17 +75,16 @@ static void
 test_cursor_calculate_move_backwards (EbSdbCursorFixture *fixture,
                                      gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         -5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    -5,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        /* Assert the last 5 contacts in en_US order */
@@ -115,22 +113,22 @@ static void
 test_cursor_calculate_back_and_forth (EbSdbCursorFixture *fixture,
                                      gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor, 
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         7, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor, 
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    7,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        g_assert_cmpint (g_slist_length (results), ==, 7);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -142,17 +140,17 @@ test_cursor_calculate_back_and_forth (EbSdbCursorFixture *fixture,
        g_assert_cmpint (total, ==, 20);
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         -4, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    -4,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        g_assert_cmpint (g_slist_length (results), ==, 4);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -164,17 +162,17 @@ test_cursor_calculate_back_and_forth (EbSdbCursorFixture *fixture,
        g_assert_cmpint (total, ==, 20);
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        g_assert_cmpint (g_slist_length (results), ==, 5);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -223,21 +221,16 @@ test_cursor_calculate_after_modification (EbSdbCursorFixture *fixture,
        EBookClient  *book_client;
        GError *error = NULL;
        gint    position = 0, total = 0;
-       GSList *results;
 
        book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
 
        /* Set the cursor to point exactly 'blackbird' (which is the 12th contact) */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         12, &error);
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    12, NULL, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
-       g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
-       g_slist_free (results);
-
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
                                                       fixture->cursor, &total, &position, &error))
@@ -288,22 +281,21 @@ static void
 test_cursor_calculate_filtered_move_forward (EbSdbCursorFixture *fixture,
                                             gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        g_assert_cmpint (g_slist_length (results), ==, 5);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -319,22 +311,22 @@ static void
 test_cursor_calculate_filtered_move_backwards (EbSdbCursorFixture *fixture,
                                               gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         -5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    -5,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        g_assert_cmpint (g_slist_length (results), ==, 5);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -383,21 +375,16 @@ test_cursor_calculate_filtered_after_modification (EbSdbCursorFixture *fixture,
        EBookClient  *book_client;
        GError *error = NULL;
        gint    position = 0, total = 0;
-       GSList *results;
 
        book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
 
        /* Set the cursor to point exactly 'blackbird' (which is the 8th contact when filtered) */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         8, &error);
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    8, NULL, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
-       g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
-       g_slist_free (results);
-
        /* 'blackbirds' -> Jacob Appelbaum */
        e_contact_set (fixture->contacts[18 - 1], E_CONTACT_FAMILY_NAME, "Appelbaum");
        e_contact_set (fixture->contacts[18 - 1], E_CONTACT_GIVEN_NAME, "Jacob");
@@ -424,17 +411,16 @@ static void
 test_cursor_calculate_descending_move_forward (EbSdbCursorFixture *fixture,
                                               gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5,
+                                                    &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        /* Assert the first 5 contacts in en_US order */
@@ -448,6 +434,7 @@ test_cursor_calculate_descending_move_forward (EbSdbCursorFixture *fixture,
                               NULL);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -463,17 +450,15 @@ static void
 test_cursor_calculate_descending_move_backwards (EbSdbCursorFixture *fixture,
                                                 gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        gint    position = 0, total = 0;
 
        /* Move cursor */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         -5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    -5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        /* Assert the last 5 contacts in en_US order */
@@ -487,6 +472,7 @@ test_cursor_calculate_descending_move_backwards (EbSdbCursorFixture *fixture,
                               NULL);
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -536,21 +522,16 @@ test_cursor_calculate_descending_after_modification (EbSdbCursorFixture *fixture
        EBookClient  *book_client;
        GError *error = NULL;
        gint    position = 0, total = 0;
-       GSList *results;
 
        book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
 
        /* Set the cursor to point exactly 'Bät' (which is the 12th contact in descending order) */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         12, &error);
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    12, NULL, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
-       g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
-       g_slist_free (results);
-
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
                                                       fixture->cursor, &total, &position, &error))
diff --git a/tests/libedata-book/test-sqlite-cursor-set-sexp.c 
b/tests/libedata-book/test-sqlite-cursor-set-sexp.c
index b5c1071..05dcc7f 100644
--- a/tests/libedata-book/test-sqlite-cursor-set-sexp.c
+++ b/tests/libedata-book/test-sqlite-cursor-set-sexp.c
@@ -36,14 +36,15 @@ test_cursor_sexp_calculate_position (EbSdbCursorFixture *fixture,
        EBookQuery *query;
        gint    position = 0, total = 0;
        gchar *sexp = NULL;
-       GSList *results, *node;
+       GSList *results = NULL, *node;
        EbSdbSearchData *data;
 
        /* Set the cursor to point exactly to 'blackbirds', which is the 12th contact in en_US */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_RESET,
-                                                         12, &error);
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_RESET,
+                                                    12, &results, &error))
+               g_error ("Error fetching cursor results: %s", error->message);
 
        /* Ensure we moved to the right contact */
        node = g_slist_last (results);
diff --git a/tests/libedata-book/test-sqlite-cursor-set-target.c 
b/tests/libedata-book/test-sqlite-cursor-set-target.c
index c2f6fec..69bc986 100644
--- a/tests/libedata-book/test-sqlite-cursor-set-target.c
+++ b/tests/libedata-book/test-sqlite-cursor-set-target.c
@@ -15,16 +15,14 @@ static void
 test_cursor_set_target_reset_cursor (EbSdbCursorFixture *fixture,
                                     gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
 
        /* First batch */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        print_results (results);
@@ -41,14 +39,13 @@ test_cursor_set_target_reset_cursor (EbSdbCursorFixture *fixture,
 
        g_slist_foreach (results, (GFunc)e_book_backend_sqlitedb_search_data_free, NULL);
        g_slist_free (results);
+       results = NULL;
 
        /* Second batch reset (same results) */
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_RESET,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_RESET,
+                                                    5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        print_results (results);
@@ -74,7 +71,7 @@ static void
 test_cursor_set_target_c_next_results (EbSdbCursorFixture *fixture,
                                       gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        ECollator *collator;
        gint n_labels;
@@ -90,12 +87,10 @@ test_cursor_set_target_c_next_results (EbSdbCursorFixture *fixture,
        e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
                                                                    fixture->cursor, 3);
 
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor,
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor,
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        print_results (results);
@@ -121,7 +116,7 @@ static void
 test_cursor_set_target_c_prev_results (EbSdbCursorFixture *fixture,
                                       gconstpointer  user_data)
 {
-       GSList *results;
+       GSList *results = NULL;
        GError *error = NULL;
        ECollator *collator;
        gint n_labels;
@@ -137,12 +132,10 @@ test_cursor_set_target_c_prev_results (EbSdbCursorFixture *fixture,
        e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
                                                                    fixture->cursor, 3);
 
-       results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                         fixture->cursor, 
-                                                         EBSDB_CURSOR_ORIGIN_CURRENT,
-                                                         -5, &error);
-
-       if (error)
+       if (!e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                    fixture->cursor, 
+                                                    EBSDB_CURSOR_ORIGIN_CURRENT,
+                                                    -5, &results, &error))
                g_error ("Error fetching cursor results: %s", error->message);
 
        print_results (results);


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