From: Bartosz Kosiorek gang65@poczta.onet.pl
This reverts commit 8df9bf057af4cb2d0b20b3cac25df12d21e7f3fb. --- dlls/msvcrt/tests/string.c | 131 +++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 4e525193ced..15db21e2455 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -92,7 +92,9 @@ static errno_t (__cdecl *p_ultoa_s)(__msvcrt_ulong,char*,size_t,int); static int *p__mb_cur_max; static unsigned char *p_mbctype; static int (__cdecl *p_wcslwr_s)(wchar_t*,size_t); +static errno_t (__cdecl *p_mbsupr_s_l)(unsigned char *str, size_t numberOfElements, _locale_t locale); static errno_t (__cdecl *p_mbsupr_s)(unsigned char *str, size_t numberOfElements); +static errno_t (__cdecl *p_mbslwr_s_l)(unsigned char *str, size_t numberOfElements, _locale_t locale); static errno_t (__cdecl *p_mbslwr_s)(unsigned char *str, size_t numberOfElements); static int (__cdecl *p_wctob)(wint_t); static wint_t (__cdecl *p_btowc)(int); @@ -133,13 +135,13 @@ static void test_swab( void ) { char expected1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#"; char expected2[] = "ABCDEFGHIJKLMNOPQRSTUVWX$"; char expected3[] = "$"; - + char from[30]; char to[30]; - + int testsize; - - /* Test 1 - normal even case */ + + /* Test 1 - normal even case */ memset(to,'$', sizeof(to)); memset(from,'@', sizeof(from)); testsize = 26; @@ -147,7 +149,7 @@ static void test_swab( void ) { _swab( from, to, testsize ); ok(memcmp(to,expected1,testsize) == 0, "Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
- /* Test 2 - uneven case */ + /* Test 2 - uneven case */ memset(to,'$', sizeof(to)); memset(from,'@', sizeof(from)); testsize = 25; @@ -155,7 +157,7 @@ static void test_swab( void ) { _swab( from, to, testsize ); ok(memcmp(to,expected2,testsize) == 0, "Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
- /* Test 3 - from = to */ + /* Test 3 - from = to */ memset(to,'$', sizeof(to)); memset(from,'@', sizeof(from)); testsize = 26; @@ -163,7 +165,7 @@ static void test_swab( void ) { _swab( to, to, testsize ); ok(memcmp(to,expected1,testsize) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
- /* Test 4 - 1 bytes */ + /* Test 4 - 1 bytes */ memset(to,'$', sizeof(to)); memset(from,'@', sizeof(from)); testsize = 1; @@ -2835,6 +2837,62 @@ static void test__mbsnbcat_s(void) "Expected the output buffer string to be "\0inosaurdu" without ending null terminator\n"); }
+static void test__mbsupr_s_l(void) +{ + errno_t ret; + unsigned char buffer[20]; + + if (!p_mbsupr_s_l) + { + win_skip("Skipping _mbsupr_s_l tests\n"); + return; + } + + errno = EBADF; + ret = p_mbsupr_s_l(NULL, 0, NULL); + ok(ret == 0, "Expected _mbsupr_s_l to return 0, got %d\n", ret); + + errno = EBADF; + ret = p_mbsupr_s_l(NULL, sizeof(buffer), NULL); + ok(ret == EINVAL, "Expected _mbsupr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); + + errno = EBADF; + ret = p_mbsupr_s_l(buffer, 0, NULL); + ok(ret == EINVAL, "Expected _mbsupr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); + + memcpy(buffer, "abcdefgh", sizeof("abcdefgh")); + errno = EBADF; + ret = p_mbsupr_s_l(buffer, sizeof("abcdefgh"), NULL); + ok(ret == 0, "Expected _mbsupr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")), + "Expected the output buffer to be "ABCDEFGH", got "%s"\n", + buffer); + + memcpy(buffer, "abcdefgh", sizeof("abcdefgh")); + errno = EBADF; + ret = p_mbsupr_s_l(buffer, sizeof(buffer), NULL); + ok(ret == 0, "Expected _mbsupr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")), + "Expected the output buffer to be "ABCDEFGH", got "%s"\n", + buffer); + + memcpy(buffer, "abcdefgh", sizeof("abcdefgh")); + errno = EBADF; + ret = p_mbsupr_s_l(buffer, 4, NULL); + ok(ret == EINVAL, "Expected _mbsupr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); + + memcpy(buffer, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop")); + errno = EBADF; + ret = p_mbsupr_s_l(buffer, sizeof(buffer), NULL); + ok(ret == 0, "Expected _mbsupr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")), + "Expected the output buffer to be "ABCDEFGH\0ijklmnop", got "%s"\n", + buffer); +} + static void test__mbsupr_s(void) { errno_t ret; @@ -2889,7 +2947,62 @@ static void test__mbsupr_s(void) ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")), "Expected the output buffer to be "ABCDEFGH\0ijklmnop", got "%s"\n", buffer); +} + +static void test__mbslwr_s_l(void) +{ + errno_t ret; + unsigned char buffer[20]; + + if (!p_mbslwr_s_l) + { + win_skip("Skipping _mbslwr_s_l tests\n"); + return; + } + + errno = EBADF; + ret = p_mbslwr_s_l(NULL, 0, NULL); + ok(ret == 0, "Expected _mbslwr_s_l to return 0, got %d\n", ret); + + errno = EBADF; + ret = p_mbslwr_s_l(NULL, sizeof(buffer), NULL); + ok(ret == EINVAL, "Expected _mbslwr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); + + errno = EBADF; + ret = p_mbslwr_s_l(buffer, 0, NULL); + ok(ret == EINVAL, "Expected _mbslwr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); + + memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH")); + errno = EBADF; + ret = p_mbslwr_s_l(buffer, sizeof("ABCDEFGH"), NULL); + ok(ret == 0, "Expected _mbslwr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")), + "Expected the output buffer to be "abcdefgh", got "%s"\n", + buffer); + + memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH")); + errno = EBADF; + ret = p_mbslwr_s_l(buffer, sizeof(buffer), NULL); + ok(ret == 0, "Expected _mbslwr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")), + "Expected the output buffer to be "abcdefgh", got "%s"\n", + buffer); + + memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH")); + errno = EBADF; + ret = p_mbslwr_s_l(buffer, 4, NULL); + ok(ret == EINVAL, "Expected _mbslwr_s_l to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
+ memcpy(buffer, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP")); + errno = EBADF; + ret = p_mbslwr_s_l(buffer, sizeof(buffer), NULL); + ok(ret == 0, "Expected _mbslwr_s_l to return 0, got %d\n", ret); + ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")), + "Expected the output buffer to be "abcdefgh\0IJKLMNOP", got "%s"\n", + buffer); }
static void test__mbslwr_s(void) @@ -4639,7 +4752,9 @@ START_TEST(string) p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s"); p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s"); p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s"); + p_mbsupr_s_l = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s_l"); p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s"); + p_mbslwr_s_l = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s_l"); p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s"); p_btowc = (void*)GetProcAddress(hMsvcrt, "btowc"); p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob"); @@ -4720,7 +4835,9 @@ START_TEST(string) test__mbsnbcat_s(); test__ultoa_s(); test__wcslwr_s(); + test__mbsupr_s_l(); test__mbsupr_s(); + test__mbslwr_s_l(); test__mbslwr_s(); test_wctob(); test_btowc();