summaryrefslogtreecommitdiff
path: root/json-glib/tests/parser.c
Commit message (Collapse)AuthorAgeFilesLines
* Replace g_print with g_test_messageEmmanuele Bassi2022-10-131-329/+153
| | | | | | | The test suite for JSON-GLib was written back when we only had gtester-report and freeform verbose test output. These days, we expect everything to conform to the Test Anything Protocol (TAP), which has specific constraints on the output format.
* Fix sign comparison warningsEmmanuele Bassi2022-10-111-14/+7
| | | | | When running with `-Wsign-compare` we're raising a lot of signed/unsigned comparison warnings.
* Drop usage of raw g_assert in reader test in favor of g_assert_*()Frederic Martinsons2022-10-111-55/+55
| | | | | | | | This will give more informative message in case of fail assertions. Moreover GLib (when compiling with G_DISABLE_ASSERT) disable g_assert totally, that would make these tests no-op Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
* json-parser: Support loading files via memory mappingPhilip Withnall2020-06-091-0/+56
| | | | | | | | | | | | | | | Add a new `json_parser_load_from_mapped_file()` to load JSON from files via memory mapping. It’s otherwise similar to `json_parser_load_from_file()`. It’s in the right position to be able to memory map the file it’s reading from: it reads the input once before building a `JsonNode` structure to represent it, doesn’t write to the file, and often deals with large input files. This should speed things up slightly due to reducing time spent allocating a large chunk of heap memory to load the file into, if a caller can support that. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* tests: Factor out a helper functionPhilip Withnall2020-06-091-9/+17
| | | | | | | This introduces no functional changes, but will allow that code to be reused in the following commit. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* json-parser: Fix getting immutable root nodes from empty inputPhilip Withnall2017-12-151-5/+17
| | | | | | | | | | | | | | If parsing an empty document, it’s allowed to return NULL from json_parser_get_root(). This was broken for immutable parsers when immutability support was added (an assertion fails). Fix that, and also document that json_parser_get_root() may return NULL. Do the same for json_parser_steal_root() too, which is another way that the root node may be NULL. Add a unit test. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* Use fuzzy comparison for floating point valuesEmmanuele Bassi2017-11-041-9/+3
| | | | | | Direct comparison should never be used for floating point values. Fixes #27 and #28.
* Allow empty string as object member nameDr. David Alan Gilbert2017-03-111-1/+2
| | | | | | | | | | | Commit 028e540 disallowed empty member names in objects, however they are unfortunately valid JSON. This patch reenables an empty string as a member name. Tests are updated to allow the empty string case, and to test the use of an empty string in generation, iteration etc. https://bugzilla.gnome.org/show_bug.cgi?id=747279
* tests: Add more checks to the parser stream unitEmmanuele Bassi2014-04-171-6/+16
|
* Remove conditional inclusion of config.hEmmanuele Bassi2014-03-181-2/+0
| | | | All the platforms and build system we support have a config.h header.
* parser: Fix all occurances of TESTS_DATA_DIREmmanuele Bassi2013-08-221-6/+1
| | | | And use g_test_build_filename().
* parser: Use the proper GLib API to find test data filesEmmanuele Bassi2013-08-221-6/+1
| | | | | | | Instead of our homegrown solution. This should fix the regression in the installed tests case. Original patch by: Colin Walters <walters@verbum.org>
* Remove compile time GLib version checkEmmanuele Bassi2013-08-211-3/+0
| | | | | We depend on a new version of GLib, so we can remove a bunch of old version checks.
* build: Add --enable-installed-testsEmmanuele Bassi2013-05-161-3/+21
| | | | | | | See https://live.gnome.org/GnomeGoals/InstalledTests for more information. It's still possible to run `make check` with locally uninstalled tests.
* tests: Put g_type_init() under conditional compilationEmmanuele Bassi2012-10-271-0/+2
| | | | | | | | Starting from GLib 2.36, g_type_init() is going to be deprecated (the type system will be initialized as soon as libgobject is paged in, using constructors). As I don't want to bump dependencies just for that, the call to g_type_init() should be placed under a compile-time version check, to keep the noise from compiler warnings down.
* tests/parser: Check negative numeric valuesEmmanuele Bassi2012-10-261-1/+15
| | | | | This is the positive equivalent of the test case inside the invalid test unit.
* tests: Move the invalid JSON unit to its own fileEmmanuele Bassi2012-10-251-52/+0
| | | | Instead of putting it inside the parser unit test.
* build: Rename test binariesEmmanuele Bassi2011-06-191-0/+785
It's pointless to add the '-test' suffix to files under the tests/ directory.