|
0
|
1 //================================================================= |
|
|
2 // |
|
|
3 // abs.c |
|
|
4 // |
|
|
5 // Testcase for C library abs() |
|
|
6 // |
|
|
7 //================================================================= |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //================================================================= |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
2
|
32 // Author(s): ctarpy, jlarmour |
|
|
33 // Contributors: jlarmour |
|
|
34 // Date: 1999-02-12 |
|
0
|
35 // Description: Contains testcode for C library abs() function |
|
|
36 // |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 |
|
|
40 // Declarations for test system: |
|
|
41 // |
|
|
42 // TESTCASE_TYPE=CYG_TEST_MODULE |
|
|
43 // COMPOUND_TESTCASE |
|
|
44 |
|
|
45 // CONFIGURATION |
|
|
46 |
|
|
47 #include <pkgconf/libc.h> // Configuration header |
|
|
48 |
|
|
49 // INCLUDES |
|
|
50 |
|
|
51 #include <stdlib.h> |
|
|
52 #include <limits.h> |
|
|
53 #include <cyg/infra/testcase.h> |
|
|
54 #include <sys/cstartup.h> // C library initialisation |
|
|
55 |
|
|
56 // FUNCTIONS |
|
|
57 |
|
|
58 externC void |
|
|
59 cyg_package_start( void ) |
|
|
60 { |
|
|
61 cyg_iso_c_start(); |
|
|
62 } // cyg_package_start() |
|
|
63 |
|
|
64 |
|
|
65 int |
|
|
66 main( int argc, char *argv[] ) |
|
|
67 { |
|
|
68 int x; |
|
|
69 |
|
|
70 CYG_TEST_INIT(); |
|
|
71 |
|
|
72 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " |
|
|
73 "library abs() function"); |
|
|
74 |
|
|
75 // Check 1 |
|
|
76 x = 5; |
|
|
77 CYG_TEST_PASS_FAIL( abs(x) == 5, "abs(5)"); |
|
|
78 |
|
|
79 // Check 2 |
|
|
80 x = -5; |
|
|
81 CYG_TEST_PASS_FAIL( abs(x) == 5, "abs(-5)"); |
|
|
82 |
|
|
83 // Check 3 |
|
|
84 x = 12345; |
|
|
85 CYG_TEST_PASS_FAIL( abs(x) == 12345, "abs(12345)"); |
|
|
86 |
|
|
87 // Check 4 |
|
|
88 x = -23456; |
|
|
89 CYG_TEST_PASS_FAIL( abs(x) == 23456, "abs(-23456"); |
|
|
90 |
|
|
91 // Check 5 |
|
|
92 x = 0; |
|
|
93 CYG_TEST_PASS_FAIL( abs(x) == 0, "abs(0)"); |
|
|
94 |
|
|
95 // Check 6 |
|
|
96 x = INT_MAX; |
|
|
97 CYG_TEST_PASS_FAIL( abs(x) == INT_MAX, "abs(INT_MAX)"); |
|
|
98 |
|
|
99 // Check 7 |
|
|
100 x = -INT_MAX; |
|
|
101 CYG_TEST_PASS_FAIL( abs(x) == INT_MAX, "abs(-INT_MAX)"); |
|
|
102 |
|
|
103 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " |
|
|
104 "library abs() function"); |
|
|
105 |
|
|
106 } // main() |
|
|
107 |
|
|
108 // EOF abs.c |