qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 01/50] qlit: add qobject_from_qlit()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 01/50] qlit: add qobject_from_qlit()
Date: Wed, 13 Sep 2017 08:51:28 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

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 <address@hidden>
> ---
>  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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]