Browse Source

* drop bitmap_t typedef

master
Alex 'AdUser' Z 8 years ago
parent
commit
f4b596a283
  1. 2
      src/bitmap.h
  2. 29
      tests/bitmap.c

2
src/bitmap.h

@ -8,8 +8,6 @@
#define CHAR_USED '@' #define CHAR_USED '@'
#define CHAR_NONE '-' #define CHAR_NONE '-'
typedef unsigned char bitmap_t[BITMAP_SIZE];
int int
bitmap_compare(const unsigned char *a, bitmap_compare(const unsigned char *a,
const unsigned char *b); const unsigned char *b);

29
tests/bitmap.c

@ -2,32 +2,31 @@
#include "../src/bitmap.h" #include "../src/bitmap.h"
int int
main() main() {
{ unsigned char a[BITMAP_SIZE], b[BITMAP_SIZE];
bitmap_t a, b;
memset (a, 0x00, sizeof(bitmap_t)); memset (a, 0x00, sizeof(a));
memset (b, 0x00, sizeof(bitmap_t)); memset (b, 0x00, sizeof(b));
assert(bitmap_compare(a, b) == 0); assert(bitmap_compare(a, b) == 0);
memset (a, 0xFE, sizeof(bitmap_t)); memset (a, 0xFE, sizeof(a));
memset (b, 0xFF, sizeof(bitmap_t)); memset (b, 0xFF, sizeof(b));
assert(bitmap_compare(a, b) == 32); assert(bitmap_compare(a, b) == 32);
memset (a, 0x00, sizeof(bitmap_t)); memset (a, 0x00, sizeof(a));
memset (b, 0x55, sizeof(bitmap_t)); memset (b, 0x55, sizeof(b));
assert(bitmap_compare(a, b) == 128); assert(bitmap_compare(a, b) == 128);
memset (a, 0x00, sizeof(bitmap_t)); memset (a, 0x00, sizeof(a));
memset (b, 0xAA, sizeof(bitmap_t)); memset (b, 0xAA, sizeof(b));
assert(bitmap_compare(a, b) == 128); assert(bitmap_compare(a, b) == 128);
memset (a, 0xAA, sizeof(bitmap_t)); memset (a, 0xAA, sizeof(a));
memset (b, 0x55, sizeof(bitmap_t)); memset (b, 0x55, sizeof(b));
assert(bitmap_compare(a, b) == 256); assert(bitmap_compare(a, b) == 256);
memset (a, 0x00, sizeof(bitmap_t)); memset (a, 0x00, sizeof(a));
memset (b, 0xFF, sizeof(bitmap_t)); memset (b, 0xFF, sizeof(b));
assert(bitmap_compare(a, b) == 256); assert(bitmap_compare(a, b) == 256);
return 0; return 0;

Loading…
Cancel
Save