Eric Blake <[email protected]> writes:
> On 02/27/2017 05:20 AM, Markus Armbruster wrote:
>> Pass &error_abort with known-good input. Else pass &err and check
>> what comes back. This demonstrates that the parser fails silently for
>> many errors.
>>
>> Signed-off-by: Markus Armbruster <[email protected]>
>> ---
>> tests/check-qjson.c | 88
>> ++++++++++++++++++++++++++++++++++-------------------
>> 1 file changed, 56 insertions(+), 32 deletions(-)
>>
>
>> @@ -809,7 +811,7 @@ static void utf8_string(void)
>> utf8_in = test_cases[i].utf8_in ?: test_cases[i].utf8_out;
>> json_out = test_cases[i].json_out ?: test_cases[i].json_in;
>>
>> - obj = qobject_from_json(json_in, NULL);
>> + obj = qobject_from_json(json_in, utf8_out ? &error_abort : NULL);
>
> This one ignores errors if utf8_out is not specified; intentional?
> Especially when compared to...
if (utf8_out) {
str = qobject_to_qstring(obj);
g_assert(str);
g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);
If @utf8_out, the conversion is expected to work and produce utf8_out.
} else {
g_assert(!obj);
Else, the conversion expected not to work. These are bugs we've known
for a long time.
}
>> static void unterminated_string(void)
>> {
>> - QObject *obj = qobject_from_json("\"abc", NULL);
>> + Error *err = NULL;
>> + QObject *obj = qobject_from_json("\"abc", &err);
>> + g_assert(!err); /* BUG */
>> g_assert(obj == NULL);
>
> change like these.
These are new bugs: the JSON parser can fail without setting an error.