Mercurial > ecos
diff 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 |
line wrap: on
line diff
--- a/packages/language/c/libc/current/tests/stdio/sprintf2.c +++ b/packages/language/c/libc/current/tests/stdio/sprintf2.c @@ -155,11 +155,25 @@ test( CYG_ADDRWORD data ) CYG_TEST_PASS_FAIL(ret == my_strlen(z), "|%5d|%10s|%03d|%c|%o| test return code" ); + // Check 3 + ret = snprintf(y, 19, "print up to here >< and not this bit" ); + my_strcpy(z, "print up to here >"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "simple snprintf test #1 return code" ); + + // Check 4 + ret = snprintf(y, 31, "print a bit of this number: %05d nyer", 1234); + my_strcpy(z, "print a bit of this number: 01"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "simple snprintf test #2 return code" ); + #ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT CYG_TEST_INFO("Starting floating point specific tests"); - // Check 3 + // Check 5 ret = sprintf(y, "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G|", 2.0, "times", 6, '=', 12.0, -2.3451e-6 ); my_strcpy(z, "|2.000000| times|006|=|+12 |-02.35E-06|"); @@ -171,6 +185,15 @@ test( CYG_ADDRWORD data ) "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test " "return code" ); + // Check 6 + ret = snprintf(y, 20, "bit of this: %g double", 6.431e8); + my_strcpy(z, "bit of this: 6.431e"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, + "snprintf double test #1"); + + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "snprintf double test #1 return code"); + #endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT CYG_TEST_FINISH("Finished tests from testcase " __FILE__
