64-bit CRC code.
[ccan] / ccan / crc / test / api.c
index c357a2cd6a252d332cd4eb1e0d552307c4fff227..5e85e35bde9aa516d4e1c01ef9f4003fd2b13455 100644 (file)
@@ -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();
 }