5 * (c) 2009 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Header files ------------------------------------------------------*/
35 /*----- Main code ---------------------------------------------------------*/
37 static int verify(dstr *v)
45 static const int step[] = { 0, 1, 5, 6, 7, 8, 23, -1 };
47 /* --- Set up for using this key --- */
49 h = *(uint32 *)v[1].buf;
51 /* --- Hash the data a lot --- */
53 for (i = 0; step[i] >= 0; i++) {
56 hh = crc32(0, v[0].buf, v[0].len);
70 fprintf(stderr, "\ncrc32 failed\n");
71 fprintf(stderr, " data = %s\n", v[0].buf);
72 fprintf(stderr, " step = %d\n", step[i]);
73 fprintf(stderr, " expected = %08lx\n", (unsigned long)h);
74 fprintf(stderr, " computed = %08lx\n", (unsigned long)hh);
80 static const test_chunk tests[] = {
81 { "hash", verify, { &type_string, &type_uint32 } },
85 int main(int argc, char *argv[])
87 test_run(argc, argv, tests, "crc32.in");
91 /*----- That's all, folks -------------------------------------------------*/