diff options
Diffstat (limited to '')
-rw-r--r-- | strrcaseeqlen.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/strrcaseeqlen.c b/strrcaseeqlen.c index d5176a1..351eaa6 100644 --- a/strrcaseeqlen.c +++ b/strrcaseeqlen.c @@ -12,6 +12,27 @@ extern inline size_t libsimple_strrcaseeqlen(const char *, const char *); int main(void) { + size_t i, j; + char a[] = "abcdefgh", b[] = "ABCDEFGH"; + + assert(libsimple_strrcaseeqlen("", "") == 0); + assert(libsimple_strrcaseeqlen("x", "") == 0); + assert(libsimple_strrcaseeqlen("x", "y") == 0); + assert(libsimple_strrcaseeqlen("", "y") == 0); + for (i = 0; i <= 8; i++) { + for (j = 0; j <= 8; j++) { + assert(libsimple_strrcaseeqlen(&a[i], &b[j]) == 8 - (i > j ? i : j)); + assert(libsimple_strrcaseeqlen(&b[i], &a[j]) == 8 - (i > j ? i : j)); + a[i] = b[j] = '\0'; + assert(libsimple_strrcaseeqlen(a, b) == (i == j ? i : 0)); + assert(libsimple_strrcaseeqlen(b, a) == (i == j ? i : 0)); + a[i] = "abcdefgh"[i]; + b[j] = "ABCDEFGH"[j]; + } + } + assert(libsimple_strrcaseeqlen("abc", "abc") == 3); + assert(libsimple_strrcaseeqlen("123", "123") == 3); + return 0; } |