On 05/11/2018 01:13 PM, Max Reitz wrote:
+ * "h": 0xffffffffffffffff,
+ * "i": true,
+ * "j": 0
Is it worth testing fun things like '-0.0'?
Sure, why not. Maybe even infinity, although I'm not quite sure the
input visitor can handle it...
JSON can't handle Inf or NaN, even if the input visitor can. So
probably best to not worry about those.
+ g_assert(!strcmp(qdict_get_str(dict, "a"), "null"));
+ g_assert(!strcmp(qdict_get_str(dict, "b"), "42"));
+ g_assert(!strcmp(qdict_get_str(dict, "c"), "-23"));
+ g_assert(!strcmp(qdict_get_str(dict, "d"), "off"));
+ g_assert(qobject_type(qdict_get(dict, "e")) == QTYPE_QNULL);
Is it worth shortening this line to:
g_assert(qobject_to(QNull, qdict_get(dict, "e")));
I think explicitly checking the type is a bit more expressive.
Okay (qobject_to() checks the type under the hood, and returns non-NULL
only when it was the right type - but I see your point about that being
a bit more magic)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org