CPlay/crc32/test.c
2025-11-14 16:31:23 +01:00

24 lines
756 B
C

#include "crc32.h"
#include <assert.h>
#include <stdio.h>
int main(void) {
assert(crc32("123456789", 9) == 0xCBF43926);
assert(crc32("", 0) == 0x00000000);
assert(crc32("a", 1) == 0xE8B7BE43);
assert(crc32("A", 1) == 0xD3D99E8B);
assert(crc32("hello", 5) == 0x3610A686);
assert(crc32("The quick brown fox jumps over the lazy dog", 43) == 0x414FA339);
assert(crc32("The quick brown fox jumps over the lazy dog.", 44) == 0x519025E9);
/* Keep in mind the update api requires initialization and finalization */
uint32_t crc = crc32_init();
crc = crc32_update_raw(crc, "a", 1);
crc = crc32_finalize(crc);
assert(crc == crc32("a", 1));
assert(crc == 0xE8B7BE43);
printf("All good!\n");
return 0;
}