qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 12/24] tests/test-cutils: Cover qemu_strtosz() w


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 12/24] tests/test-cutils: Cover qemu_strtosz() with trailing crap
Date: Tue, 14 Feb 2017 16:58:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

On 02/14/2017 04:25 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  tests/test-cutils.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 

Reviewed-by: Eric Blake <address@hidden>

> diff --git a/tests/test-cutils.c b/tests/test-cutils.c
> index 3dcd4c1..ec65d27 100644
> --- a/tests/test-cutils.c
> +++ b/tests/test-cutils.c
> @@ -1463,6 +1463,23 @@ static void test_qemu_strtosz_invalid(void)
>      g_assert(endptr == str);
>  }
>  
> +static void test_qemu_strtosz_trailing(void)
> +{
> +    const char *str;
> +    char *endptr = NULL;
> +    int64_t res;
> +
> +    str = "123xxx";
> +    res = qemu_strtosz(str, &endptr);
> +    g_assert_cmpint(res, ==, 123 * M_BYTE);
> +    g_assert(endptr == str + 3);
> +
> +    str = "1kiB";

Personally, I think this one would be useful to support, but agree that
right now it should be handled as trailing garbage.

> +    res = qemu_strtosz(str, &endptr);
> +    g_assert_cmpint(res, ==, 1024);
> +    g_assert(endptr == str + 2);
> +}
> +


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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