aboutsummaryrefslogtreecommitdiffstats
path: root/strcasestr.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-19 13:23:21 +0200
committerMattias Andrée <maandree@kth.se>2018-08-19 13:23:21 +0200
commita405c151df74d4d3b4d06c38feff6458bef375a9 (patch)
tree7a06fe944e440134ab278623b909e73e9f83d3a7 /strcasestr.c
parentAdd str[r]n[case]str and str[n][case]cmpnul (diff)
downloadlibsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.gz
libsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.bz2
libsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.xz
Add str[n]caseeq[null] and some tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--strcasestr.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/strcasestr.c b/strcasestr.c
index 4ffbde2..071b7df 100644
--- a/strcasestr.c
+++ b/strcasestr.c
@@ -23,52 +23,52 @@ libsimple_strcasestr(const char *h_, const char *n)
int
main(void)
{
- assert(!strcmp(libsimple_strcasestr("", ""), ""));
- assert(!strcmp(libsimple_strcasestr("test", ""), "test"));
+ assert(!strcmpnul(libsimple_strcasestr("", ""), ""));
+ assert(!strcmpnul(libsimple_strcasestr("test", ""), "test"));
assert(!libsimple_strcasestr("", "test"));
assert(!libsimple_strcasestr("t", "test"));
- assert(!strcmp(libsimple_strcasestr("test", "t"), "test"));
- assert(!strcmp(libsimple_strcasestr("test", "e"), "est"));
- assert(!strcmp(libsimple_strcasestr("test", "s"), "st"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "t"), "test"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "e"), "est"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "s"), "st"));
assert(!libsimple_strcasestr("test", "x"));
- assert(!strcmp(libsimple_strcasestr("test", "te"), "test"));
- assert(!strcmp(libsimple_strcasestr("test", "es"), "est"));
- assert(!strcmp(libsimple_strcasestr("test", "st"), "st"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "te"), "test"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "es"), "est"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "st"), "st"));
assert(!libsimple_strcasestr("test", "xx"));
- assert(!strcmp(libsimple_strcasestr("abc", "c"), "c"));
- assert(!strcmp(libsimple_strcasestr("abc", "bc"), "bc"));
- assert(!strcmp(libsimple_strcasestr("abc", "abc"), "abc"));
- assert(!strcmp(libsimple_strcasestr("abcabc", "bc"), "bcabc"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "c"), "c"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "bc"), "bc"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "abc"), "abc"));
+ assert(!strcmpnul(libsimple_strcasestr("abcabc", "bc"), "bcabc"));
- assert(!strcmp(libsimple_strcasestr("TEST", ""), "TEST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", ""), "TEST"));
assert(!libsimple_strcasestr("T", "test"));
- assert(!strcmp(libsimple_strcasestr("TEST", "t"), "TEST"));
- assert(!strcmp(libsimple_strcasestr("TEST", "e"), "EST"));
- assert(!strcmp(libsimple_strcasestr("TEST", "s"), "ST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "t"), "TEST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "e"), "EST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "s"), "ST"));
assert(!libsimple_strcasestr("TEST", "x"));
- assert(!strcmp(libsimple_strcasestr("TEST", "te"), "TEST"));
- assert(!strcmp(libsimple_strcasestr("TEST", "es"), "EST"));
- assert(!strcmp(libsimple_strcasestr("TEST", "st"), "ST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "te"), "TEST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "es"), "EST"));
+ assert(!strcmpnul(libsimple_strcasestr("TEST", "st"), "ST"));
assert(!libsimple_strcasestr("TEST", "xx"));
- assert(!strcmp(libsimple_strcasestr("ABC", "c"), "C"));
- assert(!strcmp(libsimple_strcasestr("ABC", "bc"), "BC"));
- assert(!strcmp(libsimple_strcasestr("ABC", "abc"), "ABC"));
- assert(!strcmp(libsimple_strcasestr("ABCABC", "bc"), "BCABC"));
+ assert(!strcmpnul(libsimple_strcasestr("ABC", "c"), "C"));
+ assert(!strcmpnul(libsimple_strcasestr("ABC", "bc"), "BC"));
+ assert(!strcmpnul(libsimple_strcasestr("ABC", "abc"), "ABC"));
+ assert(!strcmpnul(libsimple_strcasestr("ABCABC", "bc"), "BCABC"));
assert(!libsimple_strcasestr("", "TEST"));
assert(!libsimple_strcasestr("t", "TEST"));
- assert(!strcmp(libsimple_strcasestr("test", "T"), "test"));
- assert(!strcmp(libsimple_strcasestr("test", "E"), "est"));
- assert(!strcmp(libsimple_strcasestr("test", "S"), "st"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "T"), "test"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "E"), "est"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "S"), "st"));
assert(!libsimple_strcasestr("test", "X"));
- assert(!strcmp(libsimple_strcasestr("test", "TE"), "test"));
- assert(!strcmp(libsimple_strcasestr("test", "ES"), "est"));
- assert(!strcmp(libsimple_strcasestr("test", "ST"), "st"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "TE"), "test"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "ES"), "est"));
+ assert(!strcmpnul(libsimple_strcasestr("test", "ST"), "st"));
assert(!libsimple_strcasestr("test", "XX"));
- assert(!strcmp(libsimple_strcasestr("abc", "C"), "c"));
- assert(!strcmp(libsimple_strcasestr("abc", "BC"), "bc"));
- assert(!strcmp(libsimple_strcasestr("abc", "ABC"), "abc"));
- assert(!strcmp(libsimple_strcasestr("abcabc", "BC"), "bcabc"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "C"), "c"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "BC"), "bc"));
+ assert(!strcmpnul(libsimple_strcasestr("abc", "ABC"), "abc"));
+ assert(!strcmpnul(libsimple_strcasestr("abcabc", "BC"), "bcabc"));
return 0;
}