diff options
author | Lars Schneider <larsxschneider@gmail.com> | 2012-10-24 11:03:15 +0200 |
---|---|---|
committer | Lars Schneider <larsxschneider@gmail.com> | 2012-10-25 09:19:27 +0200 |
commit | f1e8583e475e32e47aa1fd7d42388b144604477b (patch) | |
tree | c5f8a45e425929d935eb8b6e1c9fa8bfa984980b /tests | |
parent | 11a4926fc6c2bfe43fef3c66ad30e4b2df612616 (diff) |
Fix -O1 warning and use proper pointers for Jansson library.
See details: https://github.com/kripken/emscripten/pull/636#issuecomment-9456782
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/runner.py b/tests/runner.py index 41b9ee19..f920defb 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5287,13 +5287,29 @@ int main(int argc, char **argv) { json_error_t error; json_t *root = json_loadb(jsonString, strlen(jsonString), 0, &error); - if(!root || !json_is_object(root)) + if(!root) { + printf("Node `root` is `null`."); return 0; + } + + if(!json_is_object(root)) { + printf("Node `root` is no object."); + return 0; + } + printf("%s\\n", json_string_value(json_object_get(root, "key"))); json_t *array = json_object_get(root, "array"); - if(!array || !json_is_array(array)) + if(!array) { + printf("Node `array` is `null`."); + return 0; + } + + if(!json_is_array(array)) { + printf("Node `array` is no array."); return 0; + } + for(size_t i=0; i<json_array_size(array); ++i) { json_t *arrayNode = json_array_get(array, i); @@ -5312,11 +5328,17 @@ int main(int argc, char **argv) { if(!numberNode || !json_is_number(numberNode) || !floatNode || !json_is_real(floatNode)) return 0; - + printf("%i\\n", json_integer_value(numberNode)); printf("%.2f\\n", json_number_value(numberNode)); printf("%.2f\\n", json_real_value(floatNode)); + json_t *invalidNode = json_object_get(dict, "invalidNode"); + if(invalidNode) + return 0; + + printf("%i\\n", json_number_value(invalidNode)); + json_decref(root); if(!json_is_object(root)) @@ -5325,7 +5347,7 @@ int main(int argc, char **argv) { return 0; } ''' - self.do_run(src, 'value\narray_item1\narray_item2\narray_item3\n3\n3.00\n2.20\njansson!') + self.do_run(src, 'value\narray_item1\narray_item2\narray_item3\n3\n3.00\n2.20\nJansson: Node with ID `0` not found. Context has `10` nodes.\n0\nJansson: No JSON context.\njansson!') ### 'Medium' tests |