|
0
|
1 //================================================================= |
|
|
2 // |
|
|
3 // atol.c |
|
|
4 // |
|
|
5 // Testcase for C library atol() |
|
|
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 |
|
0
|
34 // Date: 1998/6/3 |
|
|
35 // Description: Contains testcode for C library atol() function |
|
|
36 // |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 |
|
|
40 // Declarations for test system: |
|
|
41 // |
|
|
42 // TESTCASE_TYPE=CYG_TEST_MODULE |
|
|
43 |
|
|
44 |
|
|
45 // CONFIGURATION |
|
|
46 |
|
|
47 #include <pkgconf/libc.h> // Configuration header |
|
|
48 |
|
|
49 // INCLUDES |
|
|
50 |
|
|
51 #include <stdlib.h> |
|
|
52 #include <cyg/infra/testcase.h> |
|
|
53 #include <sys/cstartup.h> // C library initialisation |
|
|
54 |
|
|
55 // HOW TO START TESTS |
|
|
56 |
|
|
57 #if defined(CYGPKG_LIBC) |
|
|
58 |
|
|
59 # define START_TEST( test ) test(0) |
|
|
60 |
|
|
61 #else |
|
|
62 |
|
|
63 # define START_TEST( test ) CYG_EMPTY_STATEMENT |
|
|
64 |
|
|
65 #endif |
|
|
66 |
|
|
67 |
|
|
68 // FUNCTIONS |
|
|
69 |
|
|
70 externC void |
|
|
71 cyg_package_start( void ) |
|
|
72 { |
|
|
73 #ifdef CYGPKG_LIBC |
|
|
74 cyg_iso_c_start(); |
|
|
75 #else |
|
|
76 (void)main(0, NULL); |
|
|
77 #endif |
|
|
78 } // cyg_package_start() |
|
|
79 |
|
|
80 |
|
|
81 #ifdef CYGPKG_LIBC |
|
|
82 static char * |
|
|
83 my_strcpy(char *s1, const char *s2) |
|
|
84 { |
|
|
85 while (*s2 != '\0') { |
|
|
86 *(s1++) = *(s2++); |
|
|
87 } |
|
|
88 *s1 = '\0'; |
|
|
89 |
|
|
90 return s1; |
|
|
91 } // my_strcpy() |
|
|
92 |
|
|
93 |
|
|
94 static void |
|
|
95 test( CYG_ADDRWORD data ) |
|
|
96 { |
|
|
97 char x[30]; |
|
|
98 |
|
|
99 // Check 1 |
|
|
100 my_strcpy(x, "20"); |
|
|
101 CYG_TEST_PASS_FAIL( atol(x) == 20, "atol(20)"); |
|
|
102 |
|
|
103 // Check 2 |
|
|
104 my_strcpy(x, "1972"); |
|
|
105 CYG_TEST_PASS_FAIL( atol(x) == 1972, "atol(1972)"); |
|
|
106 |
|
|
107 // Check 3 |
|
|
108 my_strcpy(x, "-98765"); |
|
|
109 CYG_TEST_PASS_FAIL( atol(x) == -98765, "atol(-98765)"); |
|
|
110 |
|
|
111 // Check 4 |
|
|
112 my_strcpy(x, " -98765xxx"); |
|
|
113 CYG_TEST_PASS_FAIL( atol(x) == -98765, "atol( -98765xxx)"); |
|
|
114 |
|
|
115 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " |
|
|
116 "atol() function"); |
|
|
117 } // test() |
|
|
118 |
|
|
119 #endif // ifndef CYGPKG_LIBC |
|
|
120 |
|
|
121 int |
|
|
122 main(int argc, char *argv[]) |
|
|
123 { |
|
|
124 CYG_TEST_INIT(); |
|
|
125 |
|
|
126 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " |
|
|
127 "atol() function"); |
|
|
128 |
|
|
129 START_TEST( test ); |
|
|
130 |
|
2
|
131 CYG_TEST_NA("Testing is not applicable to this configuration"); |
|
0
|
132 } // main() |
|
|
133 |
|
|
134 // EOF atol.c |