X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcrc%2Ftest%2Fapi.c;h=1d56e3d2969000616212585e2b52d3407c188173;hb=c39bd505849acdf77744e24b5db7263003911c08;hp=c357a2cd6a252d332cd4eb1e0d552307c4fff227;hpb=9d724ba2aa3b69cc56d20e5f578b2c1399e965f6;p=ccan diff --git a/ccan/crc/test/api.c b/ccan/crc/test/api.c index c357a2cd..1d56e3d2 100644 --- a/ccan/crc/test/api.c +++ b/ccan/crc/test/api.c @@ -1,5 +1,5 @@ -#include "crc/crc.h" -#include "tap/tap.h" +#include +#include #include static const uint32_t crc32c_tab[] = { @@ -238,12 +238,24 @@ static void test_crc32(uint32_t (*crc)(uint32_t, const void *, size_t), ok1(memcmp(crc_table(), table_expect, 1024) == 0); } +static void test_crc64(void) +{ + /* according to http://swissknife.sourceforge.net/CRC64.html */ + ok1(crc64_iso(0, "IHATEMATH", strlen("IHATEMATH")) + == 0xE3DCADD69B01ADD1ULL); + + /* according to the CRC64 poly, http://sf.net/projects/jcrcgen */ + ok1(crc64_iso(0, "123456789", strlen("123456789")) + == 0x46A5A9388A5BEFFEULL); +} + int main(int argc, char *argv[]) { - plan_tests(517 * 2); + plan_tests(517 * 2 + 2); test_crc32(crc32c, crc32c_table, crcc_zero_expect, crcc_expect, crc32c_tab); test_crc32(crc32_ieee, crc32_ieee_table, crc_ieee_zero_expect, crc_ieee_expect, crc32_ieee_tab); + test_crc64(); return exit_status(); }