basic: bitmap - complete fix for bitshift overflow

The bug found by David existed in several places, fix them all. Also
extend the tests to cover these cases.
This commit is contained in:
Tom Gundersen
2015-07-17 18:59:16 +02:00
parent 511ed79917
commit cdf6f5ae04
2 changed files with 15 additions and 7 deletions
+8
View File
@@ -58,6 +58,14 @@ int main(int argc, const char *argv[]) {
assert_se(bitmap_isset(b, 256) == false);
assert_se(bitmap_isclear(b) == true);
assert_se(bitmap_set(b, 32) == 0);
bitmap_unset(b, 0);
assert_se(bitmap_isset(b, 32) == true);
bitmap_unset(b, 32);
BITMAP_FOREACH(n, NULL, it)
assert_not_reached("NULL bitmap");
assert_se(bitmap_set(b, 0) == 0);
assert_se(bitmap_set(b, 1) == 0);
assert_se(bitmap_set(b, 256) == 0);