diff options
Diffstat (limited to 'stpntolower.c')
-rw-r--r-- | stpntolower.c | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/stpntolower.c b/stpntolower.c index 9aca9f9..de4e74e 100644 --- a/stpntolower.c +++ b/stpntolower.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include "libsimple.h" +#include "common.h" #ifndef TEST @@ -10,11 +10,11 @@ libsimple_stpntolower(char *d, const char *s, size_t n) char *ret; if (d == s) { for (; n && *d; d++, n--) - *d = tolower(*d); + *d = (char)tolower(*d); return d; } else if (d < s) { for (; n && *s; d++, s++, n--) - *d = tolower(*s); + *d = (char)tolower(*s); if (n) *d = '\0'; return d; @@ -22,9 +22,9 @@ libsimple_stpntolower(char *d, const char *s, size_t n) for (i = 0; i < n && s[i]; i++); ret = &d[i]; if (i != n) - d[i] = tolower(s[i]); + d[i] = (char)tolower(s[i]); while (i--) - d[i] = tolower(s[i]); + d[i] = (char)tolower(s[i]); return ret; } } @@ -47,15 +47,6 @@ main(void) stpcpy(buf, "ABCDEabcde12345"); assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], SIZE_MAX), "")); assert(!strcmp(buf, "abcdeabcde12345")); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], SIZE_MAX), "abcdeabcde12345")); - assert(!strcmp(buf, "ABCabcdeabcde12345")); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], SIZE_MAX), "deabcde12345")); - assert(!strcmp(buf, "deabcde12345")); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], SIZE_MAX), "abcdeabcde12345")); - assert(!strcmp(buf, "abcdeabcde12345")); memset(buf, 0, sizeof(buf)); stpcpy(buf, "ABCDEabcde12345"); @@ -70,19 +61,6 @@ main(void) stpcpy(buf, "ABCDEabcde12345X"); assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], 15), "X")); assert(!strcmp(buf, "abcdeabcde12345X")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345"); - buf[18] = 'X'; - assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 15), "abcdeabcde12345X")); - assert(!strcmp(buf, "ABCabcdeabcde12345X")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 12), "deabcde12345345")); - assert(!strcmp(buf, "deabcde12345345")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345X"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 15), "abcdeabcde12345X")); - assert(!strcmp(buf, "abcdeabcde12345X")); memset(buf, 0, sizeof(buf)); stpcpy(buf, "ABCDEabcde12345"); @@ -96,18 +74,6 @@ main(void) stpcpy(buf, "ABCDEabcde12345"); assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], 0), "ABCDEabcde12345")); assert(!strcmp(buf, "ABCDEabcde12345")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 0), "DEabcde12345")); - assert(!strcmp(buf, "ABCDEabcde12345")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 0), "ABCDEabcde12345")); - assert(!strcmp(buf, "ABCDEabcde12345")); - memset(buf, 0, sizeof(buf)); - stpcpy(buf, "ABCDEabcde12345"); - assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 0), "ABCDEabcde12345")); - assert(!strcmp(buf, "ABCDEabcde12345")); return 0; } |