qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 11/36] qdict: Introduce qdict_rename_keys()


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v2 11/36] qdict: Introduce qdict_rename_keys()
Date: Thu, 22 Feb 2018 23:40:20 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-02-21 14:53, Kevin Wolf wrote:
> A few block drivers will need to rename .bdrv_create options for their
> QAPIfication, so let's have a helper function for that.
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  include/qapi/qmp/qdict.h |   6 +++
>  qobject/qdict.c          |  34 ++++++++++++++
>  tests/check-qdict.c      | 113 
> +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 153 insertions(+)

[...]

> diff --git a/tests/check-qdict.c b/tests/check-qdict.c
> index ec628f3453..5f8f3be9ff 100644
> --- a/tests/check-qdict.c
> +++ b/tests/check-qdict.c
> @@ -665,6 +665,117 @@ static void qdict_crumple_test_empty(void)

[...]

> +    /* Renames are processed top to bottom */
> +    renames = (QDictRenames[]) {
> +        { "abc",        "tmp" },
> +        { "abcdef",     "abc" },
> +        { "number",     "abcdef" },
> +        { "flag",       "number" },
> +        { "nothing",    "flag" },
> +        { "tmp",        "nothing" },
> +        { NULL , NULL }
> +    };

A bit confusing to follow, but I guess nobody will have to follow it
after me and Eric.

> +    copy = qdict_clone_shallow(dict);
> +    qdict_rename_keys(copy, renames, &error_abort);
> +
> +    g_assert_cmpstr(qdict_get_str(copy, "nothing"), ==, "foo");
> +    g_assert_cmpstr(qdict_get_str(copy, "abc"), ==, "bar");
> +    g_assert_cmpint(qdict_get_int(copy, "abcdef"), ==, 42);
> +    g_assert_cmpint(qdict_get_bool(copy, "number"), ==, true);
> +    g_assert(qobject_type(qdict_get(copy, "flag")) == QTYPE_QNULL);
> +    g_assert(!qdict_haskey(copy, "tmp"));
> +
> +    QDECREF(copy);
> +
> +    /* Conflicting renam */

*rename

With that fixed:

Reviewed-by: Max Reitz <address@hidden>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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