From d350af24554ccf7253bf02984650b65ae1847a20 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Thu, 30 Mar 2023 22:28:37 +1100 Subject: [PATCH] kernel32/tests: Test GetConsoleOriginalTitleW() with an empty title. --- dlls/kernel32/tests/console.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 9e42c5b6c3b..8d569ad6410 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -4283,6 +4283,15 @@ static void test_GetConsoleOriginalTitleW(void) ok(ret == title_len, "got %lu, expected %lu\n", ret, title_len); } +static void test_GetConsoleOriginalTitleW_empty(void) +{ + WCHAR buf[64]; + DWORD ret; + + ret = GetConsoleOriginalTitleW(buf, ARRAY_SIZE(buf)); + ok(!ret, "GetConsoleOriginalTitleW failed: %lu\n", GetLastError()); +} + static void test_GetConsoleOriginalTitle(void) { STARTUPINFOA si = { sizeof(si) }; @@ -4299,6 +4308,14 @@ static void test_GetConsoleOriginalTitle(void) CloseHandle(info.hThread); wait_child_process(info.hProcess); CloseHandle(info.hProcess); + + strcat(buf, " empty"); + title[0] = 0; + ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); + ok(ret, "CreateProcess failed: %lu\n", GetLastError()); + CloseHandle(info.hThread); + wait_child_process(info.hProcess); + CloseHandle(info.hProcess); } static void test_GetConsoleTitleA(void) @@ -4944,10 +4961,15 @@ START_TEST(console) ExitProcess(exit_code); } - if (argc == 3 && !strcmp(argv[2], "title_test")) + if (argc >= 3 && !strcmp(argv[2], "title_test")) { - test_GetConsoleOriginalTitleA(); - test_GetConsoleOriginalTitleW(); + if (argc == 3) + { + test_GetConsoleOriginalTitleA(); + test_GetConsoleOriginalTitleW(); + } + else + test_GetConsoleOriginalTitleW_empty(); return; }