comparison tests/test-crc.c @ 6357:9abdb1386cc0

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