These tests are to resolve the concerns about relying on the tested behaviors, that were brought up at https://gitlab.winehq.org/wine/wine/-/merge_requests/4060#note_48218.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/msvcrt/tests/string.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 6a9dc23d4f0..02eaa7a0b4b 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -642,10 +642,10 @@ static void test_mbsspnp( void)
static void test_strdup(void) { - char *str; - str = _strdup( 0 ); - ok( str == 0, "strdup returns %s should be 0\n", str); - free( str ); + char *str = strdup(0); + errno = 0xdeadbeef; + ok(str == 0, "strdup returned %s, expected NULL\n", wine_dbgstr_a(str)); + ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno); }
static void test_strcmp(void)
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/msvcrt/tests/string.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 02eaa7a0b4b..db280255064 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -648,6 +648,14 @@ static void test_strdup(void) ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno); }
+static void test_wcsdup(void) +{ + WCHAR *str = wcsdup(0); + errno = 0xdeadbeef; + ok(str == 0, "wcsdup returned %s, expected NULL\n", wine_dbgstr_w(str)); + ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno); +} + static void test_strcmp(void) { int ret = p_strcmp( "abc", "abcd" ); @@ -4704,6 +4712,7 @@ START_TEST(string) test_mbsspn(); test_mbsspnp(); test_strdup(); + test_wcsdup(); test_strcmp(); test_strcpy_s(); test_memcpy_s();
Piotr Caban (@piotr) commented about dlls/msvcrt/tests/string.c:
ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
}
+static void test_wcsdup(void) +{
- WCHAR *str = wcsdup(0);
- errno = 0xdeadbeef;
Please set errno before calling `wcsdup(0)`.