qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 08/13] tests: Add qdict_stringify_for_keyval() t


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH 08/13] tests: Add qdict_stringify_for_keyval() test
Date: Fri, 11 May 2018 20:13:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 2018-05-10 18:02, Eric Blake wrote:
> On 05/09/2018 11:55 AM, Max Reitz wrote:
>> Signed-off-by: Max Reitz <address@hidden>
>> ---
>>   tests/check-qdict.c | 54
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 54 insertions(+)
>>
> 
>> +static void qdict_stringify_for_keyval_test(void)
>> +{
>> +    QDict *dict = qdict_new();
>> +
>> +    /*
>> +     * Test stringification of:
>> +     *
>> +     * {
>> +     *     "a": "null",
>> +     *     "b": 42,
>> +     *     "c": -23,
>> +     *     "d": false,
>> +     *     "e": null,
>> +     *     "f": "",
>> +     *     "g": 0.5,
>> +     *     "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...
>> +    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.

Max

> Reviewed-by: Eric Blake <address@hidden>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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