[json-glib/json-glib-0-12] tests: Gracefully handle missing g_assert_error()



commit 80e9c9666a8f51b4210cfe6d36bf4b2443ec6a2b
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Jan 10 11:26:38 2011 +0000

    tests: Gracefully handle missing g_assert_error()
    
    We depend on GLib â?¥ 2.16, but g_assert_error() landed in GLib 2.20; use
    a fallback depending on a compile-time version check to avoid breaking
    compilation of the test suite.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632190

 json-glib/tests/parser-test.c |    7 +++++++
 json-glib/tests/reader-test.c |   12 ++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/json-glib/tests/parser-test.c b/json-glib/tests/parser-test.c
index d3f2404..80877c7 100644
--- a/json-glib/tests/parser-test.c
+++ b/json-glib/tests/parser-test.c
@@ -673,7 +673,14 @@ test_invalid_json (void)
                                         &error);
 
       g_assert (!res);
+
+#if GLIB_CHECK_VERSION (2, 20, 0)
       g_assert_error (error, JSON_PARSER_ERROR, test_invalid[i].code);
+#else
+      g_assert (error != NULL);
+      g_assert (error->domain == JSON_PARSER_ERROR);
+      g_assert (error->code == test_invalid[i].code);
+#endif
 
       if (g_test_verbose ())
         g_print ("Error: %s\n", error->message);
diff --git a/json-glib/tests/reader-test.c b/json-glib/tests/reader-test.c
index b0990b8..be327c0 100644
--- a/json-glib/tests/reader-test.c
+++ b/json-glib/tests/reader-test.c
@@ -33,9 +33,15 @@ test_base_object (void)
 
   g_assert (!json_reader_read_member (reader, "bar"));
   g_assert (json_reader_get_error (reader) != NULL);
+#if GLIB_CHECK_VERSION (2, 20, 0)
   g_assert_error ((GError *) json_reader_get_error (reader),
                   JSON_READER_ERROR,
                   JSON_READER_ERROR_INVALID_MEMBER);
+#else
+  g_assert (json_reader_get_error (reader) != NULL);
+  g_assert (json_reader_get_error (reader)->domain == JSON_READER_ERROR);
+  g_assert (json_reader_ger_error (reader)->code == JSON_READER_ERROR_INVALID_MEMBER);
+#endif
   json_reader_end_member (reader);
   g_assert (json_reader_get_error (reader) == NULL);
 
@@ -84,9 +90,15 @@ test_base_array (void)
   json_reader_end_element (reader);
 
   g_assert (!json_reader_read_element (reader, 7));
+#if GLIB_CHECK_VERSION (2, 20, 0)
   g_assert_error ((GError *) json_reader_get_error (reader),
                   JSON_READER_ERROR,
                   JSON_READER_ERROR_INVALID_INDEX);
+#else
+  g_assert (json_reader_get_error (reader) != NULL);
+  g_assert (json_reader_get_error (reader)->domain == JSON_READER_ERROR);
+  g_assert (json_reader_get_error (reader)->code == JSON_READER_ERROR_INVALID_INDEX);
+#endif
   json_reader_end_element (reader);
   g_assert (json_reader_get_error (reader) == NULL);
 



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