2009-02-10 19:16:52 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <conio.h>
|
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
int fails = 0;
|
|
|
|
|
2009-02-10 19:16:52 +00:00
|
|
|
static int do_test(const char *s1, const char *s2, size_t n)
|
|
|
|
{
|
|
|
|
printf("strnicmp(\"%s\", \"%s\", %d): ", s1, s2, (int)n);
|
|
|
|
return strncasecmp(s1, s2, n);
|
|
|
|
}
|
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
static void printresult(int ret)
|
2009-02-10 19:16:52 +00:00
|
|
|
{
|
2020-07-13 19:26:07 +00:00
|
|
|
if (ret) {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("fail (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
|
|
|
} else {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("OK (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 19:16:52 +00:00
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
static void printresultgt(int ret)
|
|
|
|
{
|
|
|
|
if (ret >= 0) {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("fail (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
|
|
|
} else {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("OK (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 19:16:52 +00:00
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
static void printresultlt(int ret)
|
|
|
|
{
|
|
|
|
if (ret <= 0) {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("fail (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
|
|
|
} else {
|
2009-02-10 19:16:52 +00:00
|
|
|
printf("OK (%d)\n", ret);
|
2020-07-13 19:26:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = do_test("Wurzl", "wURZL", 5);
|
|
|
|
printresult(ret);
|
|
|
|
|
|
|
|
ret = do_test("Wurzl", "wURZL", 6);
|
|
|
|
printresult(ret);
|
|
|
|
|
|
|
|
ret = do_test("Wurzl", "wURZL", 10);
|
|
|
|
printresult(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("Wurzla", "wURZLB", 10);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresultgt(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("Wurzla", "wURZLb", 5);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresult(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("BLI", "bla", 5);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresultlt(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("", "bla", 5);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresultgt(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("BLI", "", 5);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresultlt(ret);
|
2009-02-10 19:16:52 +00:00
|
|
|
|
|
|
|
ret = do_test("", "", 5);
|
2020-07-13 19:26:07 +00:00
|
|
|
printresult(ret);
|
|
|
|
|
|
|
|
printf("fails: %d\n", fails);
|
|
|
|
|
|
|
|
#if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__)
|
2013-05-28 19:56:37 +00:00
|
|
|
cgetc();
|
2020-07-13 19:26:07 +00:00
|
|
|
#endif
|
|
|
|
return fails;
|
2009-02-10 19:16:52 +00:00
|
|
|
}
|