2 var liba = require("../liba");
3 function assert(expr) {
8 function do_leak_check() {
9 for (const arg of arguments) {
12 if (liba.do_leak_check) {
16 var text = "0123456789";
17 var crc = new liba.crc8(0x07);
18 assert("crc.eval(text, 0) == 0x45");
19 assert("crc.eval(crc.pack(text, 0), 0) == 0");
21 var crc = new liba.crc8(0x31, true);
22 assert("crc.eval(text, 0) == 0x75");
23 assert("crc.eval(crc.pack(text, 0), 0) == 0");
25 var crc = new liba.crc16(0x1021);
26 assert("crc.eval(text, 0) == 0x9C58");
27 assert("crc.eval(crc.pack(text, 0), 0) == 0");
29 var crc = new liba.crc16(0x8005, true);
30 assert("crc.eval(text, 0) == 0x443D");
31 assert("crc.eval(crc.pack(text, 0), 0) == 0");
33 var crc = new liba.crc32(0x1EDC6F41);
34 assert("crc.eval(text, 0) == 0x512B456E");
35 assert("crc.eval(crc.pack(text, 0), 0) == 0");
37 var crc = new liba.crc32(0x04C11DB7, true);
38 assert("crc.eval(text, 0) == 0x450EAFB0");
39 assert("crc.eval(crc.pack(text, 0), 0) == 0");
42 var crc = new liba.crc64(0x000000000000001Bn);
43 assert("crc.eval(text, 0n) == 0xE4FFBEA588AFC790n");
44 assert("crc.eval(crc.pack(text, 0n), 0n) == 0n");
46 var crc = new liba.crc64(0x42F0E1EBA9EA3693n, true);
47 assert("crc.eval(text, 0n) == 0xDA60676A5CDE0008n");
48 assert("crc.eval(crc.pack(text, 0n), 0n) == 0n");