crc32.spec.ts (626B)
1 export const description = ` 2 Test for crc32 utility functions. 3 `; 4 5 import { makeTestGroup } from '../common/framework/test_group.js'; 6 import { crc32, toHexString } from '../common/util/crc32.js'; 7 8 import { UnitTest } from './unit_test.js'; 9 10 class F extends UnitTest { 11 test(content: string, expect: string): void { 12 const got = toHexString(crc32(content)); 13 this.expect( 14 expect === got, 15 ` 16 expected: ${expect} 17 got: ${got}` 18 ); 19 } 20 } 21 22 export const g = makeTestGroup(F); 23 24 g.test('strings').fn(t => { 25 t.test('', '00000000'); 26 t.test('hello world', '0d4a1185'); 27 t.test('123456789', 'cbf43926'); 28 });