Files
mars-nwe/tests/nwnss/bitmap/test_nwnss_bitmap.c
Mario Fetka 0f82de2743
All checks were successful
Source release / source-package (push) Successful in 1m20s
0536 build: introduce libnwnss for imported NSS runtime
2026-06-14 22:34:04 +02:00

49 lines
982 B
C

#include "library/bitmap.h"
#include <stdio.h>
#define CHECK(expr) \
do { \
if (!(expr)) { \
fprintf(stderr, "CHECK failed at %s:%d: %s\n", __FILE__, __LINE__, #expr); \
return 1; \
} \
} while (0)
int main(void)
{
BitMap_s map;
SNINT start;
CHECK(newBitMap(&map, 20) == &map);
CHECK(getMaxBits(&map) == 20);
CHECK(countBits(&map) == 20);
CHECK(testABit(&map, 0));
CHECK(testABit(&map, 19));
start = findBits(&map, 4);
CHECK(start == 0);
CHECK(countBits(&map) == 16);
CHECK(!testABit(&map, 0));
CHECK(!testABit(&map, 3));
CHECK(testABit(&map, 4));
setAbit(&map, 1);
CHECK(testABit(&map, 1));
clearAbit(&map, 1);
CHECK(!testABit(&map, 1));
clearBits(&map, 8, 4);
CHECK(!testABit(&map, 8));
CHECK(!testABit(&map, 11));
setBits(&map, 8, 2);
CHECK(testABit(&map, 8));
CHECK(testABit(&map, 9));
CHECK(!testABit(&map, 10));
start = findBits(&map, 4);
CHECK(start == 4);
freeBitMap(&map);
return 0;
}