On 09/11/2017 06:05 AM, Marc-André Lureau wrote: > Instanciate a QObject* form a literal QLitObject.
s/Instanciate/Instantiate/ s/form/from/ > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > include/qapi/qmp/qlit.h | 2 ++ > qobject/qlit.c | 36 ++++++++++++++++++++++++++++++++++++ > tests/check-qlit.c | 26 ++++++++++++++++++++++++++ > 3 files changed, 64 insertions(+) > +QObject *qobject_from_qlit(const QLitObject *qlit) > +{ > + switch (qlit->type) { > + case QTYPE_QNULL: > + return QOBJECT(qnull()); > + case QTYPE_QNUM: > + return QOBJECT(qnum_from_int(qlit->value.qnum)); Is this going to work for all QNum values? > +++ b/tests/check-qlit.c > @@ -64,11 +64,37 @@ static void qlit_equal_qobject_test(void) > qobject_decref(qobj); > } > > +static void qobject_from_qlit_test(void) > +{ > + QObject *obj, *qobj = qobject_from_qlit(&qlit); > + QDict *qdict; > + QList *bee; > + > + qdict = qobject_to_qdict(qobj); > + g_assert_cmpint(qdict_get_int(qdict, "foo"), ==, 42); > + g_assert_cmpstr(qdict_get_str(qdict, "bar"), ==, "hello world"); > + g_assert(qobject_type(qdict_get(qdict, "baz")) == QTYPE_QNULL); Related to my question above - you pass because there are no floating point values in qlit. Is that something we want supported? -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature