comparison packages/services/crc/current/tests/crc_test.c @ 277:544b77bfb6d5

* Created a new package from the CRC routines embedded in RedBoot.
author asl
date Fri, 09 Aug 2002 10:27:03 +0000
parents
children 38b5627c5569
comparison
equal deleted inserted replaced
276:ca456a5c2de6 277:544b77bfb6d5
1 //=================================================================
2 //
3 // crc_test.c
4 //
5 // crc test cases
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 2002 Andrew Lunn
12 //
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
16 //
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // for more details.
21 //
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 //
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
32 //
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
35 //
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
42 //
43 // Author(s): asl
44 // Contributors: asl
45 // Date: 2002-08-06
46 // Description: Tests the calculation code
47 //####DESCRIPTIONEND####
48
49 #include <cyg/infra/testcase.h>
50 #include <cyg/crc/crc.h>
51
52 static char license_txt[] =
53 " GNU GENERAL PUBLIC LICENSE
54 Version 2, June 1991
55
56 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
57 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
58 Everyone is permitted to copy and distribute verbatim copies
59 of this license document, but changing it is not allowed.
60
61 Preamble
62
63 The licenses for most software are designed to take away your
64 freedom to share and change it. By contrast, the GNU General Public
65 License is intended to guarantee your freedom to share and change free
66 software--to make sure the software is free for all its users. This
67 General Public License applies to most of the Free Software
68 Foundation's software and to any other program whose authors commit to
69 using it. (Some other Free Software Foundation software is covered by
70 the GNU Library General Public License instead.) You can apply it to
71 your programs, too.";
72
73 externC void
74 cyg_start( void )
75 {
76 CYG_TEST_INIT();
77
78 CYG_TEST_INFO("Calculating CRCs");
79
80 if (1500790746l != cyg_posix_crc32(license_txt,sizeof(license_txt)-1)) {
81 CYG_TEST_FAIL("Wrong POSIX CRC32 calculation");
82 } else {
83 CYG_TEST_PASS("POSIX CRC32 calculation");
84 }
85
86 if (1247800780 != cyg_crc32(license_txt,sizeof(license_txt)-1)) {
87 CYG_TEST_FAIL("Wrong Gary S. Browns' crc32 calculation");
88 } else {
89 CYG_TEST_PASS("Gary S. Browns' crc32 calculation");
90 }
91
92 if (32256 != cyg_crc16(license_txt,sizeof(license_txt)-1)) {
93 CYG_TEST_FAIL_FINISH("Wrong 16bit CRC calculation");
94 } else {
95 CYG_TEST_PASS_FINISH("16bit CRC calculation");
96 }
97 }
98
99
100