diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-10 20:36:44 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-10 20:36:44 +0100 |
commit | 6ad1ef901b7a07bc8b070e64c4bf5e53f708cb7b (patch) | |
tree | 91ba47496c1be5fb3ef895f254fad5af41705a93 /tests/port | |
parent | 4d32ec5ab668d02c5b3dee83f0d8275b70e9014d (diff) | |
download | wolfbones-6ad1ef901b7a07bc8b070e64c4bf5e53f708cb7b.tar.gz wolfbones-6ad1ef901b7a07bc8b070e64c4bf5e53f708cb7b.tar.bz2 |
fixed snprintf on native Windows
Diffstat (limited to 'tests/port')
-rw-r--r-- | tests/port/Makefile.W32 | 6 | ||||
-rw-r--r-- | tests/port/test_snprintf.c | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/port/Makefile.W32 b/tests/port/Makefile.W32 index 18eb2d7..befea27 100644 --- a/tests/port/Makefile.W32 +++ b/tests/port/Makefile.W32 @@ -11,7 +11,8 @@ TEST_BINS = \ test_strerror_r.exe \ test_strcasecmp.exe \ test_strncasecmp.exe \ - test_localtime_r.exe + test_localtime_r.exe \ + test_snprintf.exe !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk @@ -21,6 +22,7 @@ test_strerror_r.exe: test_strerror_r.obj test_strcasecmp.exe: test_strcasecmp.obj test_strncasecmp.exe: test_strncasecmp.obj test_localtime_r.exe: test_localtime_r.obj +test_snprintf.exe: test_snprintf.obj local_all: @@ -39,3 +41,5 @@ local_test: @test_strncasecmp >NUL 2>NUL @echo Testing localtime_r.. @test_localtime_r >NUL 2>NUL + @echo Testing snprintf.. + @test_snprintf >NUL 2>NUL diff --git a/tests/port/test_snprintf.c b/tests/port/test_snprintf.c index a9ddb45..14d7adb 100644 --- a/tests/port/test_snprintf.c +++ b/tests/port/test_snprintf.c @@ -21,14 +21,18 @@ int main( void ) { /* test if we get the same things for the most important format strings */ res1 = rpl_snprintf( buf1, 255, "test with %s %d %lu", "test", 12, 234443334L ); res2 = snprintf( buf2, 255, "test with %s %d %lu", "test", 12, 234443334L ); - res3 = snprintf( buf3, 255, "test with %s %d %lu", "test", 12, 234443334L ); + res3 = sprintf( buf3, "test with %s %d %lu", "test", 12, 234443334L ); + printf( "RPL snprintf: %d %s\nsnprintf: %d %s\nsprintf: %d %s\n", + res1, buf1, res2, buf2, res3, buf3 ); if( res1 != res2 || res1 != res3 || res1 != 27 ) return EXIT_FAILURE; if( strcmp( buf1, buf2 ) != 0 || strcmp( buf1, buf2 ) != 0 ) return EXIT_FAILURE; /* most important, does the overflow protection work */ small_res1 = rpl_snprintf( small_buf1, 10, "%s", "12345678901234" ); - small_res2 = rpl_snprintf( small_buf2, 10, "%s", "12345678901234" ); + small_res2 = snprintf( small_buf2, 10, "%s", "12345678901234" ); + printf( "RPL snprintf: %d %s\nsnprintf: %d %s\n", + small_res1, small_buf1, small_res2, small_buf2 ); if( small_res1 != small_res2 || small_res1 != 14 ) return EXIT_FAILURE; if( small_buf1[9] != '\0' || small_buf2[9] != '\0' ) return EXIT_FAILURE; if( strcmp( small_buf1, small_buf2 ) != 0 ) return EXIT_FAILURE; |