summaryrefslogtreecommitdiff
path: root/json-glib/tests/parser-test.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2010-03-19 11:04:00 +0000
committerEmmanuele Bassi <ebassi@linux.intel.com>2010-03-19 11:10:10 +0000
commit9ce82f8052290f3956c3d80c8739c214da314d42 (patch)
tree29d9cadea8fc166374bec695afdfcd59e3ba88ed /json-glib/tests/parser-test.c
parent9d7c58b4fb5edeb8e9413acc9d509447e13962e5 (diff)
downloadjson-glib-9ce82f8052290f3956c3d80c8739c214da314d42.tar.gz
parser: Return specific error codes
The JsonScanner error reporting mechanism, which is basically GScanner's, sucks beyond belief. In order to report an error code we need to store it inside the JsonParser private structure and then use it when creating the GError inside the error handler. This, frankly, is quite stupid.
Diffstat (limited to 'json-glib/tests/parser-test.c')
-rw-r--r--json-glib/tests/parser-test.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/json-glib/tests/parser-test.c b/json-glib/tests/parser-test.c
index 8f461ef..8fb11b1 100644
--- a/json-glib/tests/parser-test.c
+++ b/json-glib/tests/parser-test.c
@@ -131,14 +131,15 @@ static const struct
static const struct
{
const gchar *str;
+ JsonParserError code;
} test_invalid[] = {
- { "test" },
- { "[ foo, ]" },
- { "[ true, ]" },
- { "{ \"foo\" : true \"bar\" : false }" },
- { "[ true, [ false, ] ]" },
- { "{ \"foo\" : { \"bar\" : false, } }" },
- { "[ { }, { }, { }, ]" }
+ { "test", JSON_PARSER_ERROR_INVALID_BAREWORD },
+ { "[ foo, ]", JSON_PARSER_ERROR_INVALID_BAREWORD },
+ { "[ true, ]", JSON_PARSER_ERROR_TRAILING_COMMA },
+ { "{ \"foo\" : true \"bar\" : false }", JSON_PARSER_ERROR_MISSING_COMMA },
+ { "[ true, [ false, ] ]", JSON_PARSER_ERROR_TRAILING_COMMA },
+ { "{ \"foo\" : { \"bar\" : false, } }", JSON_PARSER_ERROR_TRAILING_COMMA },
+ { "[ { }, { }, { }, ]", JSON_PARSER_ERROR_TRAILING_COMMA }
};
static guint n_test_base_values = G_N_ELEMENTS (test_base_values);
@@ -671,8 +672,7 @@ test_invalid_json (void)
&error);
g_assert (!res);
- g_assert (error != NULL);
- g_assert (error->domain == JSON_PARSER_ERROR);
+ g_assert_error (error, JSON_PARSER_ERROR, test_invalid[i].code);
if (g_test_verbose ())
g_print ("Error: %s\n", error->message);