crc32
This commit is contained in:
parent
7383d6e0f2
commit
8f4ea26303
4 changed files with 147 additions and 0 deletions
24
crc32/test.c
Normal file
24
crc32/test.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue