Eric Blake <ebl...@redhat.com> writes: > It's simpler to have a single conversion function that takes a > bool parameter, rather than two functions where the choice of > function determines an internal bool. Similar to commit fc471c18. > > While at it, the conversion currently cannot fail (maybe it SHOULD > be possible to choose to fail, when encountering invalid UTF-8 > encoding or an Infinity or NaN valued double, but that's a story > for another day), so clean up callers to avoid a needless assert. > And use bool rather than int for 'pretty'. > > Signed-off-by: Eric Blake <ebl...@redhat.com> [...] > diff --git a/tests/check-qobject-json.c b/tests/check-qobject-json.c > index d889501..9814282 100644 > --- a/tests/check-qobject-json.c > +++ b/tests/check-qobject-json.c > @@ -64,7 +64,7 @@ static void escaped_string(void) > g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded); > > if (test_cases[i].skip == 0) { > - str = qobject_to_json(obj); > + str = qobject_to_json(obj, false); > g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].encoded); > qobject_decref(obj); > } > @@ -98,7 +98,7 @@ static void simple_string(void) > str = qobject_to_qstring(obj); > g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); > > - str = qobject_to_json(obj); > + str = qobject_to_json(obj, false); > g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); > > qobject_decref(obj); > @@ -832,13 +832,8 @@ static void utf8_string(void) > qobject_decref(obj); > > obj = QOBJECT(qstring_from_str(utf8_in)); > - str = qobject_to_json(obj); > - if (json_out) { > - g_assert(str); > - g_assert_cmpstr(qstring_get_str(str), ==, json_out); > - } else {
Unreachable, because json_out can be null only when test_cases[o].json_in is, and null json_in would've crashed in qobject_from_json(). > - g_assert(!str); > - } > + str = qobject_to_json(obj, false); > + g_assert_cmpstr(qstring_get_str(str), ==, json_out); > QDECREF(str); > qobject_decref(obj); > Thanks for cleaning up my mess. [...]