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

Re: [libvirt] [PATCH 3/2] string: test VIR_STRDUP



On 05/07/2013 11:42 PM, Eric Blake wrote:
> The surest way to avoid regressions is to test documented behavior :)
> 
> * tests/virstringtest.c (testStrdup): New test case.
> 
> Signed-off-by: Eric Blake <eblake redhat com>
> ---
>  tests/virstringtest.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 48 insertions(+), 1 deletion(-)
> 
...
> +    value = VIR_STRNDUP(array[i++], NULL, 5);
> +    if (value != 0) {
> +        fprintf(stderr, "unexpected strdup result %d, expected 0\n", value);
> +        goto cleanup;
> +    }
> +    if (i != 2) {
> +        fprintf(stderr, "unexpected side effects i=%zu, expected 2\n", i);
> +        goto cleanup;
> +    }

Should we test the side effects for the other two arguments as well?

> +    if (STRNEQ_NULLABLE(array[0], "hello") || array[1]) {
> +        fprintf(stderr, "incorrect array contents '%s' '%s'\n",
> +                NULLSTR(array[0]), NULLSTR(array[1]));
> +        goto cleanup;
> +    }
> +
> +    ret = 0;

ACK

Jan


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