diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 18:58:54 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-02-22 18:58:54 +0100 |
commit | 72fc4fc728f28306afe74cc6d4d6f2e345aea67b (patch) | |
tree | 611be8facf908314322383ae9fa613a31d1532c6 /tests/port | |
parent | d92e188e4b4c53e89ba55ae54a10802f156fdf19 (diff) | |
download | wolfbones-72fc4fc728f28306afe74cc6d4d6f2e345aea67b.tar.gz wolfbones-72fc4fc728f28306afe74cc6d4d6f2e345aea67b.tar.bz2 |
added test for strncasecmp
Diffstat (limited to 'tests/port')
-rw-r--r-- | tests/port/GNUmakefile | 5 | ||||
-rw-r--r-- | tests/port/test_strncasecmp.c | 24 |
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/port/GNUmakefile b/tests/port/GNUmakefile index e8e3257..0e83dd8 100644 --- a/tests/port/GNUmakefile +++ b/tests/port/GNUmakefile @@ -9,7 +9,8 @@ INCLUDE_DIRS = \ BINS = \ test_strdup$(EXE) \ test_strerror_r$(EXE) \ - test_strcasecmp$(EXE) + test_strcasecmp$(EXE) \ + test_strncasecmp$(EXE) -include $(TOPDIR)/makefiles/sub.mk @@ -26,4 +27,6 @@ local_test: all @./test_strerror_r >/dev/null @echo "Testing strcasecmp.." @./test_strcasecmp >/dev/null + @echo "Testing strncasecmp.." + @./test_strncasecmp >/dev/null diff --git a/tests/port/test_strncasecmp.c b/tests/port/test_strncasecmp.c new file mode 100644 index 0000000..a16a664 --- /dev/null +++ b/tests/port/test_strncasecmp.c @@ -0,0 +1,24 @@ +#include "port/sys.h" + +#undef HAVE_STRCASECMP +#include "port/string.c" /* for strcasecmp */ +#undef strncasecmp + +#include <stdlib.h> /* for EXIT_SUCCESS, EXIT_FAILURE */ + +int main( void ) { + const char *s1 = "test"; + const char *s2 = "TESTING"; + const char *s3 = "tes"; + const char *s4 = "sest"; + const char *s5 = "uest"; + + 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; + if( wolf_port_strncasecmp( s1, s3, 3 ) != 0 ) return EXIT_FAILURE; + if( wolf_port_strncasecmp( s1, s4, 3 ) <= 0 ) return EXIT_FAILURE; + if( wolf_port_strncasecmp( s1, s5, 3 ) >= 0 ) return EXIT_FAILURE; + + return EXIT_SUCCESS; +} |