Skip to content

Commit

Permalink
strnicmp unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
CurlyMoo committed Apr 22, 2018
1 parent 29b7e3e commit cf479a0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/common.c
Expand Up @@ -535,6 +535,36 @@ static void test_stricmp(CuTest *tc) {
CuAssertIntEquals(tc, 0, xfree());
}

static void test_strnicmp(CuTest *tc) {
printf("[ %-48s ]\n", __FUNCTION__);
fflush(stdout);

memtrack();

int n = strnicmp("A", "a", 1);
CuAssertIntEquals(tc, 0, n);

n = strnicmp("A", "a", 0);
CuAssertIntEquals(tc, 0, n);

n = strnicmp("Hello World!", "hello world!", 12);
CuAssertIntEquals(tc, 0, n);

n = strnicmp("Hello World!", "hello", 5);
CuAssertIntEquals(tc, 0, n);

n = strnicmp("Hello World!", "hello", 12);
CuAssertTrue(tc, (n != 0));

n = strnicmp("HelloWorld!", "Hello W", 7);
CuAssertTrue(tc, (n != 0));

n = strnicmp("Hello World!", "hELLO wO", 8);
CuAssertIntEquals(tc, 0, n);

CuAssertIntEquals(tc, 0, xfree());
}

static void test_file_get_contents(CuTest *tc) {
printf("[ %-48s ]\n", __FUNCTION__);
fflush(stdout);
Expand Down Expand Up @@ -680,6 +710,7 @@ CuSuite *suite_common(void) {
SUITE_ADD_TEST(suite, test_uniq_space);
SUITE_ADD_TEST(suite, test_str_replace);
SUITE_ADD_TEST(suite, test_stricmp);
SUITE_ADD_TEST(suite, test_strnicmp);
SUITE_ADD_TEST(suite, test_file_get_contents);
SUITE_ADD_TEST(suite, test_calc_time_interval);

Expand Down

0 comments on commit cf479a0

Please sign in to comment.