comparison packages/language/c/libc/current/tests/stdio/sprintf2.c @ 76:435cced73e2f ecos-v1_3_1-release

eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
author jlarmour
date Tue, 28 Mar 2000 14:10:45 +0000
parents bf00f99aec69
children
comparison
equal deleted inserted replaced
75:41bf073c0c32 76:435cced73e2f
153 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "|%5d|%10s|%03d|%c|%o| test"); 153 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "|%5d|%10s|%03d|%c|%o| test");
154 154
155 CYG_TEST_PASS_FAIL(ret == my_strlen(z), 155 CYG_TEST_PASS_FAIL(ret == my_strlen(z),
156 "|%5d|%10s|%03d|%c|%o| test return code" ); 156 "|%5d|%10s|%03d|%c|%o| test return code" );
157 157
158 // Check 3
159 ret = snprintf(y, 19, "print up to here >< and not this bit" );
160 my_strcpy(z, "print up to here >");
161 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #1");
162 CYG_TEST_PASS_FAIL(ret == my_strlen(z),
163 "simple snprintf test #1 return code" );
164
165 // Check 4
166 ret = snprintf(y, 31, "print a bit of this number: %05d nyer", 1234);
167 my_strcpy(z, "print a bit of this number: 01");
168 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #2");
169 CYG_TEST_PASS_FAIL(ret == my_strlen(z),
170 "simple snprintf test #2 return code" );
171
158 #ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT 172 #ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
159 173
160 CYG_TEST_INFO("Starting floating point specific tests"); 174 CYG_TEST_INFO("Starting floating point specific tests");
161 175
162 // Check 3 176 // Check 5
163 ret = sprintf(y, "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G|", 177 ret = sprintf(y, "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G|",
164 2.0, "times", 6, '=', 12.0, -2.3451e-6 ); 178 2.0, "times", 6, '=', 12.0, -2.3451e-6 );
165 my_strcpy(z, "|2.000000| times|006|=|+12 |-02.35E-06|"); 179 my_strcpy(z, "|2.000000| times|006|=|+12 |-02.35E-06|");
166 180
167 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, 181 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0,
169 183
170 CYG_TEST_PASS_FAIL(ret == my_strlen(z), 184 CYG_TEST_PASS_FAIL(ret == my_strlen(z),
171 "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test " 185 "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test "
172 "return code" ); 186 "return code" );
173 187
188 // Check 6
189 ret = snprintf(y, 20, "bit of this: %g double", 6.431e8);
190 my_strcpy(z, "bit of this: 6.431e");
191 CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0,
192 "snprintf double test #1");
193
194 CYG_TEST_PASS_FAIL(ret == my_strlen(z),
195 "snprintf double test #1 return code");
196
174 #endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT 197 #endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
175 198
176 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ 199 CYG_TEST_FINISH("Finished tests from testcase " __FILE__
177 " for C library sprintf() function"); 200 " for C library sprintf() function");
178 201