annotate tests/test-crc.c @ 6935:c7a96bfc8c0e

2006-07-07 Simon Josefsson <jas@extundo.com> * tests/test-crc.c: Change expected crc value, the test vector were probably computed using the old broken crc.c?
author Simon Josefsson <simon@josefsson.org>
date Thu, 06 Jul 2006 23:56:00 +0000
parents 9abdb1386cc0
children 260df799e469
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6357
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
1 /*
6935
c7a96bfc8c0e 2006-07-07 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents: 6357
diff changeset
2 * Copyright (C) 2005, 2006 Free Software Foundation
6357
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
3 *
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
6 * the Free Software Foundation; either version 2, or (at your option)
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
7 * any later version.
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
8 *
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
12 * GNU General Public License for more details.
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
13 *
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
17 * 02110-1301, USA. */
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
18
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
19 /* Written by Simon Josefsson. */
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
20
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
22 # include <config.h>
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
23 #endif
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
24
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
25 #include "crc.h"
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
26
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
27 #include <stdio.h>
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
28
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
29 int
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
30 main (int argc, char *argv[])
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
31 {
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
32 uint32_t p;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
33
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
34 p = crc32_update_no_xor (42, "foo", 3);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
35 if (p != 0x46e87f05)
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
36 {
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
37 printf ("cunx got %lx\n", p);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
38 return 1;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
39 }
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
40
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
41 p = crc32_no_xor ("foo", 3);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
42 if (p != 0x7332bc33)
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
43 {
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
44 printf ("cnx got %lx\n", p);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
45 return 1;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
46 }
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
47
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
48 p = crc32_update (42, "foo", 3);
6935
c7a96bfc8c0e 2006-07-07 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents: 6357
diff changeset
49 if (p != 0xb9a9a617)
6357
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
50 {
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
51 printf ("cu got %lx\n", p);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
52 return 1;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
53 }
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
54
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
55 p = crc32 ("foo", 3);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
56 if (p != 0x8c736521)
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
57 {
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
58 printf ("c got %lx\n", p);
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
59 return 1;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
60 }
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
61
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
62 return 0;
9abdb1386cc0 Add crc module.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
63 }