Commit 36e56ad1 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32/tests: Fix FormatMessage test failures on various Windows versions.

parent 0e26e741
...@@ -121,6 +121,7 @@ static void test_message_from_string_wide(void) ...@@ -121,6 +121,7 @@ static void test_message_from_string_wide(void)
static const WCHAR s_sp001sp002[] = {' ',' ','0','0','1',',',' ',' ','0','0','0','2',0}; static const WCHAR s_sp001sp002[] = {' ',' ','0','0','1',',',' ',' ','0','0','0','2',0};
static const WCHAR s_sp002sp001[] = {' ',' ','0','0','0','2',',',' ',' ','0','0','1',0}; static const WCHAR s_sp002sp001[] = {' ',' ','0','0','0','2',',',' ',' ','0','0','1',0};
static const WCHAR s_sp002sp003[] = {' ',' ','0','0','0','2',',',' ','0','0','0','0','3',0}; static const WCHAR s_sp002sp003[] = {' ',' ','0','0','0','2',',',' ','0','0','0','0','3',0};
static const WCHAR s_sp001004[] = {' ',' ','0','0','1',',','0','0','0','0','0','4',0};
WCHAR out[0x100] = {0}; WCHAR out[0x100] = {0};
DWORD r, error; DWORD r, error;
...@@ -337,7 +338,8 @@ static void test_message_from_string_wide(void) ...@@ -337,7 +338,8 @@ static void test_message_from_string_wide(void)
ok(r==11,"failed: r=%d\n",r); ok(r==11,"failed: r=%d\n",r);
r = doitW(FORMAT_MESSAGE_FROM_STRING, fmt_1oou3oou, r = doitW(FORMAT_MESSAGE_FROM_STRING, fmt_1oou3oou,
0, 0, out, sizeof(out)/sizeof(WCHAR), 5, 3, 1, 6, 4, 2 ); 0, 0, out, sizeof(out)/sizeof(WCHAR), 5, 3, 1, 6, 4, 2 );
ok(!lstrcmpW( s_sp001sp002, out),"failed out=[%s]\n", wine_dbgstr_w(out)); ok(!lstrcmpW( s_sp001sp002, out) || broken(!lstrcmpW(s_sp001004, out)),
"failed out=[%s]\n", wine_dbgstr_w(out));
ok(r==12,"failed: r=%d\n",r); ok(r==12,"failed: r=%d\n",r);
/* args are not counted the same way with an argument array */ /* args are not counted the same way with an argument array */
{ {
...@@ -573,35 +575,42 @@ static void test_message_from_string(void) ...@@ -573,35 +575,42 @@ static void test_message_from_string(void)
ok(r==3, "failed: r=%d\n",r); ok(r==3, "failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*s!", r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*s!",
0, 0, out, sizeof(out), 4, "t"); 0, 0, out, sizeof(out), 4, "t");
ok(!strcmp( " t", out),"failed out=[%s]\n",out); if (!strcmp("*s",out)) win_skip( "width/precision not supported\n" );
ok(r==4,"failed: r=%d\n",r); else
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4.2u!",
0, 0, out, sizeof(out), 3 );
ok(!strcmp( " 03", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!",
0, 0, out, sizeof(out), 5, 3, 1 );
ok(!strcmp( " 001", out),"failed out=[%s]\n",out);
ok(r==5,"failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%1!*.*u!",
0, 0, out, sizeof(out), 5, 3, 1, 4, 2 );
ok(!strcmp( " 001, 0002", out),"failed out=[%s]\n",out);
ok(r==11,"failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
ok(!strcmp( " 001, 0002", out),"failed out=[%s]\n",out);
ok(r==12,"failed: r=%d\n",r);
/* args are not counted the same way with an argument array */
{ {
ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 }; ok(!strcmp( " t", out),"failed out=[%s]\n",out);
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, ok(r==4,"failed: r=%d\n",r);
"%1!*.*u!,%1!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args ); r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4.2u!",
ok(!strcmp(" 0002, 00003", out),"failed out=[%s]\n",out); 0, 0, out, sizeof(out), 3 );
ok(r==13,"failed: r=%d\n",r); ok(!strcmp( " 03", out),"failed out=[%s]\n",out);
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, ok(r==4,"failed: r=%d\n",r);
"%1!*.*u!,%4!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args ); r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!",
ok(!strcmp(" 0002, 001", out),"failed out=[%s]\n",out); 0, 0, out, sizeof(out), 5, 3, 1 );
ok(!strcmp( " 001", out),"failed out=[%s]\n",out);
ok(r==5,"failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%1!*.*u!",
0, 0, out, sizeof(out), 5, 3, 1, 4, 2 );
ok(!strcmp( " 001, 0002", out),"failed out=[%s]\n",out);
ok(r==11,"failed: r=%d\n",r);
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
/* older Win versions marked as broken even though this is arguably the correct behavior */
/* but the new (brain-damaged) behavior is specified on MSDN */
ok(!strcmp( " 001, 0002", out) || broken(!strcmp(" 001,000004", out)),
"failed out=[%s]\n",out);
ok(r==12,"failed: r=%d\n",r); ok(r==12,"failed: r=%d\n",r);
/* args are not counted the same way with an argument array */
{
ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 };
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
"%1!*.*u!,%1!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
ok(!strcmp(" 0002, 00003", out),"failed out=[%s]\n",out);
ok(r==13,"failed: r=%d\n",r);
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
"%1!*.*u!,%4!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
ok(!strcmp(" 0002, 001", out),"failed out=[%s]\n",out);
ok(r==12,"failed: r=%d\n",r);
}
} }
/* change of pace... test the low byte of dwflags */ /* change of pace... test the low byte of dwflags */
...@@ -677,35 +686,41 @@ static void test_message_from_hmodule(void) ...@@ -677,35 +686,41 @@ static void test_message_from_hmodule(void)
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL); MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL);
error = GetLastError(); error = GetLastError();
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_FOUND, "last error %u\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL); MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL);
error = GetLastError(); error = GetLastError();
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL); MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL);
error = GetLastError(); error = GetLastError();
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), out, sizeof(out)/sizeof(CHAR), NULL); MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), out, sizeof(out)/sizeof(CHAR), NULL);
error = GetLastError(); error = GetLastError();
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
error == ERROR_MR_MID_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_LOADED,
"last error %u\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), out, sizeof(out)/sizeof(CHAR), NULL); MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), out, sizeof(out)/sizeof(CHAR), NULL);
error = GetLastError(); error = GetLastError();
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_RESOURCE_LANG_NOT_FOUND, "last error %u\n", error); ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
error == ERROR_MR_MID_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_FOUND,
"last error %u\n", error);
} }
START_TEST(format_msg) START_TEST(format_msg)
......
...@@ -1559,6 +1559,15 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x) ...@@ -1559,6 +1559,15 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
#define ERROR_SXS_THREAD_QUERIES_DISABLED 14010 #define ERROR_SXS_THREAD_QUERIES_DISABLED 14010
#define ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET 14011 #define ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET 14011
#define ERROR_SXS_CORRUPTION 14083 #define ERROR_SXS_CORRUPTION 14083
#define ERROR_MUI_FILE_NOT_FOUND 15100
#define ERROR_MUI_INVALID_FILE 15101
#define ERROR_MUI_INVALID_RC_CONFIG 15102
#define ERROR_MUI_INVALID_LOCALE_NAME 15103
#define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME 15104
#define ERROR_MUI_FILE_NOT_LOADED 15105
#define ERROR_RESOURCE_ENUM_USER_STOP 15106
#define ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED 15107
#define ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME 15108
/* HRESULT values for OLE, SHELL and other Interface stuff */ /* HRESULT values for OLE, SHELL and other Interface stuff */
/* the codes 4000-40ff are reserved for OLE */ /* the codes 4000-40ff are reserved for OLE */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment