diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 19:21:48 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 19:21:48 +0100 |
commit | 7da6a6353bd0e93da3be913345777de96589adda (patch) | |
tree | f1a4a2bcd2622f6328896456a9972f32b6b7b239 /tests/port | |
parent | 72fc4fc728f28306afe74cc6d4d6f2e345aea67b (diff) | |
download | wolfbones-7da6a6353bd0e93da3be913345777de96589adda.tar.gz wolfbones-7da6a6353bd0e93da3be913345777de96589adda.tar.bz2 |
fixed all porting tests (compile always with both versions, the one of the platform and the stub)
Diffstat (limited to 'tests/port')
-rw-r--r-- | tests/port/test_strcasecmp.c | 10 | ||||
-rw-r--r-- | tests/port/test_strdup.c | 12 | ||||
-rw-r--r-- | tests/port/test_strerror_r.c | 8 | ||||
-rw-r--r-- | tests/port/test_strncasecmp.c | 9 |
4 files changed, 30 insertions, 9 deletions
diff --git a/tests/port/test_strcasecmp.c b/tests/port/test_strcasecmp.c index e6fb40b..82ea785 100644 --- a/tests/port/test_strcasecmp.c +++ b/tests/port/test_strcasecmp.c @@ -2,9 +2,7 @@ #undef HAVE_STRCASECMP #include "port/string.c" /* for strcasecmp */ -#undef strcasecmp - -#include <strings.h> +#undef strcasecmp #include <stdlib.h> /* for EXIT_SUCCESS, EXIT_FAILURE */ @@ -15,6 +13,12 @@ int main( void ) { const char *s4 = "sest"; const char *s5 = "uest"; + if( strcasecmp( s1, s1 ) != 0 ) return EXIT_FAILURE; + if( strcasecmp( s1, s2 ) != 0 ) return EXIT_FAILURE; + if( strcasecmp( s1, s3 ) <= 0 ) return EXIT_FAILURE; + if( strcasecmp( s1, s4 ) <= 0 ) return EXIT_FAILURE; + if( strcasecmp( s1, s5 ) >= 0 ) return EXIT_FAILURE; + if( wolf_port_strcasecmp( s1, s1 ) != 0 ) return EXIT_FAILURE; if( wolf_port_strcasecmp( s1, s2 ) != 0 ) return EXIT_FAILURE; if( wolf_port_strcasecmp( s1, s3 ) <= 0 ) return EXIT_FAILURE; diff --git a/tests/port/test_strdup.c b/tests/port/test_strdup.c index 557aa03..1853404 100644 --- a/tests/port/test_strdup.c +++ b/tests/port/test_strdup.c @@ -8,11 +8,13 @@ int main( void ) { const char *s = "test"; - int res = EXIT_SUCCESS; - char *d = wolf_port_strdup( s ); - - if( strcmp( s, d ) != 0 ) res = EXIT_FAILURE; + char *d = strdup( s ); + char *d2 = wolf_port_strdup( s ); + + if( strcmp( s, d ) != 0 ) return EXIT_FAILURE; + if( strcmp( d, d2 ) != 0 ) return EXIT_FAILURE; free( d ); + free( d2 ); - exit( res ); + return EXIT_SUCCESS; } diff --git a/tests/port/test_strerror_r.c b/tests/port/test_strerror_r.c index 72b41c5..05244cd 100644 --- a/tests/port/test_strerror_r.c +++ b/tests/port/test_strerror_r.c @@ -16,6 +16,14 @@ int main( void ) { for( i = 0; i < 255; i++ ) { errno = 0; *buf = '\0'; + res = strerror_r( i, buf, 1024 ); + printf( "%d: %d \"%s\"\n", i, res, buf ); + } + + /* go through signal numbers (TODO: find out how many of them there are!) */ + for( i = 0; i < 255; i++ ) { + errno = 0; + *buf = '\0'; res = wolf_port_strerror_r( i, buf, 1024 ); printf( "%d: %d \"%s\"\n", i, res, buf ); } diff --git a/tests/port/test_strncasecmp.c b/tests/port/test_strncasecmp.c index a16a664..da1eb93 100644 --- a/tests/port/test_strncasecmp.c +++ b/tests/port/test_strncasecmp.c @@ -1,6 +1,6 @@ #include "port/sys.h" -#undef HAVE_STRCASECMP +#undef HAVE_STRNCASECMP #include "port/string.c" /* for strcasecmp */ #undef strncasecmp @@ -13,6 +13,13 @@ int main( void ) { const char *s4 = "sest"; const char *s5 = "uest"; + if( strncasecmp( s1, s1, 4 ) != 0 ) return EXIT_FAILURE; + if( strncasecmp( s1, s2, 4 ) != 0 ) return EXIT_FAILURE; + if( strncasecmp( s1, s2, 3 ) != 0 ) return EXIT_FAILURE; + if( strncasecmp( s1, s3, 3 ) != 0 ) return EXIT_FAILURE; + if( strncasecmp( s1, s4, 3 ) <= 0 ) return EXIT_FAILURE; + if( strncasecmp( s1, s5, 3 ) >= 0 ) return EXIT_FAILURE; + if( wolf_port_strncasecmp( s1, s1, 4 ) != 0 ) return EXIT_FAILURE; if( wolf_port_strncasecmp( s1, s2, 4 ) != 0 ) return EXIT_FAILURE; if( wolf_port_strncasecmp( s1, s2, 3 ) != 0 ) return EXIT_FAILURE; |