Skip to content

Commit

Permalink
[CRTDLL_APITEST] Oops. Fix that other compiler. CORE-16933
Browse files Browse the repository at this point in the history
  • Loading branch information
ThFabba committed Jan 12, 2024
1 parent c8aba5a commit 286d460
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
20 changes: 10 additions & 10 deletions modules/rostests/apitests/crt/_mbsncmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,38 @@ START_TEST(_mbsncmp)
ret = _mbsncmp(NULL, NULL, 0);
ok(ret == 0, "ret = %d\n", ret);

ret = _mbsncmp("a", "c", 0);
ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 0);
ok(ret == 0, "ret = %d\n", ret);

/* No null checks - length 1 crashes */
StartSeh()
(void)_mbsncmp("a", NULL, 1);
(void)_mbsncmp((const unsigned char *)"a", NULL, 1);
EndSeh(STATUS_ACCESS_VIOLATION);

StartSeh()
(void)_mbsncmp(NULL, "c", 1);
(void)_mbsncmp(NULL, (const unsigned char *)"c", 1);
EndSeh(STATUS_ACCESS_VIOLATION);

/* Strings longer than or equal to length */
ret = _mbsncmp("a", "c", 1);
ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 1);
ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);

ret = _mbsncmp("a", "a", 1);
ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"a", 1);
ok(ret == 0, "ret = %d\n", ret);

ret = _mbsncmp("ab", "aB", 1);
ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"aB", 1);
ok(ret == 0, "ret = %d\n", ret);

ret = _mbsncmp("aa", "ac", 2);
ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"ac", 2);
ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);

/* Length longer than one of the strings */
ret = _mbsncmp("a", "ac", 2);
ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"ac", 2);
ok(ret == DIFF_RETURN(-, 'c'), "ret = %d\n", ret);

ret = _mbsncmp("aa", "a", 2);
ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"a", 2);
ok(ret == DIFF_RETURN(+, 'a'), "ret = %d\n", ret);

ret = _mbsncmp("ab", "ab", 100);
ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"ab", 100);
ok(ret == 0, "ret = %d\n", ret);
}
48 changes: 24 additions & 24 deletions modules/rostests/apitests/crt/_mbsstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,66 +22,66 @@ START_TEST(_mbsstr)
EndSeh(STATUS_ACCESS_VIOLATION);

StartSeh()
haystack = "hello";
haystack = (unsigned char *)"hello";
(void)_mbsstr(haystack, NULL);
EndSeh(STATUS_ACCESS_VIOLATION);

StartSeh()
haystack = "";
haystack = (unsigned char *)"";
(void)_mbsstr(haystack, NULL);
EndSeh(STATUS_ACCESS_VIOLATION);

/* Empty needle returns haystack, empty haystack returns NULL... */
haystack = "hello";
ret = _mbsstr(haystack, "");
haystack = (unsigned char *)"hello";
ret = _mbsstr(haystack, (const unsigned char *)"");
ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "";
ret = _mbsstr(haystack, "a");
haystack = (unsigned char *)"";
ret = _mbsstr(haystack, (const unsigned char *)"a");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);

/* ... but if both are empty, behavior differs */
haystack = "";
ret = _mbsstr(haystack, "");
haystack = (unsigned char *)"";
ret = _mbsstr(haystack, (const unsigned char *)"");
#ifdef TEST_CRTDLL
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
#else
ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);
#endif

/* Simple "found" cases */
haystack = "abcdefg";
ret = _mbsstr(haystack, "abc");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"abc");
ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "abcdefg";
ret = _mbsstr(haystack, "g");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"g");
ok(ret == haystack + 6, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "abcdefg";
ret = _mbsstr(haystack, "abcdefg");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"abcdefg");
ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);

/* Simple "not found" cases */
haystack = "abcdefg";
ret = _mbsstr(haystack, "h");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"h");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "abcdefg";
ret = _mbsstr(haystack, "gh");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"gh");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "abcdefg";
ret = _mbsstr(haystack, "abcD");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"abcD");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);

/* Needle longer than haystack */
haystack = "abcdefg";
ret = _mbsstr(haystack, "abcdefgh");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"abcdefgh");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);

haystack = "abcdefg";
ret = _mbsstr(haystack, "xxxxxxxx");
haystack = (unsigned char *)"abcdefg";
ret = _mbsstr(haystack, (const unsigned char *)"xxxxxxxx");
ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
}

0 comments on commit 286d460

Please sign in to comment.