diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 18:54:28 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 18:54:28 +0100 |
commit | d92e188e4b4c53e89ba55ae54a10802f156fdf19 (patch) | |
tree | fc177ff92704aecb47a1a8d8a6e0971dfdd8ad05 /tests/port | |
parent | 2b55ffee666c795e5b639cacf147ab4798b17044 (diff) | |
download | wolfbones-d92e188e4b4c53e89ba55ae54a10802f156fdf19.tar.gz wolfbones-d92e188e4b4c53e89ba55ae54a10802f156fdf19.tar.bz2 |
started to add string.h replacements
Diffstat (limited to 'tests/port')
-rw-r--r-- | tests/port/GNUmakefile | 6 | ||||
-rw-r--r-- | tests/port/test_strcasecmp.c | 25 |
2 files changed, 30 insertions, 1 deletions
diff --git a/tests/port/GNUmakefile b/tests/port/GNUmakefile index 228fe92..e8e3257 100644 --- a/tests/port/GNUmakefile +++ b/tests/port/GNUmakefile @@ -8,7 +8,8 @@ INCLUDE_DIRS = \ BINS = \ test_strdup$(EXE) \ - test_strerror_r$(EXE) + test_strerror_r$(EXE) \ + test_strcasecmp$(EXE) -include $(TOPDIR)/makefiles/sub.mk @@ -23,3 +24,6 @@ local_test: all @./test_strdup >/dev/null @echo "Testing strerror_r..." @./test_strerror_r >/dev/null + @echo "Testing strcasecmp.." + @./test_strcasecmp >/dev/null + diff --git a/tests/port/test_strcasecmp.c b/tests/port/test_strcasecmp.c new file mode 100644 index 0000000..e6fb40b --- /dev/null +++ b/tests/port/test_strcasecmp.c @@ -0,0 +1,25 @@ +#include "port/sys.h" + +#undef HAVE_STRCASECMP +#include "port/string.c" /* for strcasecmp */ +#undef strcasecmp + +#include <strings.h> + +#include <stdlib.h> /* for EXIT_SUCCESS, EXIT_FAILURE */ + +int main( void ) { + const char *s1 = "test"; + const char *s2 = "TEST"; + const char *s3 = "tes"; + const char *s4 = "sest"; + const char *s5 = "uest"; + + 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; + if( wolf_port_strcasecmp( s1, s4 ) <= 0 ) return EXIT_FAILURE; + if( wolf_port_strcasecmp( s1, s5 ) >= 0 ) return EXIT_FAILURE; + + return EXIT_SUCCESS; +} |