From: Marc Hartmayer Date: Wed, 6 Jul 2016 12:02:28 +0000 (+0200) Subject: tests: Add test cases for the empty bitmap X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1edf20a9f87eb5873394182f470e191a9c70f9cf;p=libvirt.git tests: Add test cases for the empty bitmap As the empty bitmap exists, we should also test it. This patch adds test cases for the procedures 'virBitmapNextSetBit', 'virBitmapLastSetBit', 'virBitmapNextClearBit'. Tested-by: Sascha Silbe Reviewed-by: Sascha Silbe Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 009fa0dad3..a17ef82fb8 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -191,6 +191,23 @@ test4(const void *data ATTRIBUTE_UNUSED) if (ARRAY_CARDINALITY(bitsPos) + ARRAY_CARDINALITY(bitsPosInv) != size) goto error; + /* 0. empty set */ + + if (!(bitmap = virBitmapNewEmpty())) + goto error; + + if (virBitmapNextSetBit(bitmap, -1) != -1) + goto error; + + if (virBitmapLastSetBit(bitmap) != -1) + goto error; + + if (virBitmapNextClearBit(bitmap, -1) != -1) + goto error; + + virBitmapFree(bitmap); + bitmap = NULL; + /* 1. zero set */ bitmap = virBitmapNew(size);