[libvirt] [PATCH 3/2] string: test VIR_STRDUP
Ján Tomko
jtomko at redhat.com
Tue May 14 12:50:07 UTC 2013
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 at 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
More information about the libvir-list
mailing list