kernel32: add more tests for FormatMessage{A,W}
>FormatMessage uses the same backend to find the requested resource as >FindResource does, so I'd guess that they both fail in the same way >when a resource id or a language does not exist in the module. I still fail to see how I can call FindResource for a missing message-id. In the end they both use LdrFindResource_U but I guess that's not what you meant to test. I still have tthe problem to first load the messagetable with FindResource, and I cannot use a call to FindResource to ask for a present or missing message-id. I'll resend the patch with your other two suggenstions, if the patch is not accepted i'll leave it to someone else (more experienced) to take this up
Re: kernel32: add more tests for FormatMessage{A,W}
"Louis Lenders" wrote: FormatMessage uses the same backend to find the requested resource as FindResource does, so I'd guess that they both fail in the same way when a resource id or a language does not exist in the module. Parsing an actual resource data is not necessary. ok, but isn't that test already in tests/resource.c? See code snippet below: Or do i get it wrong? Probably the tests do not cover the paths you need. -- Dmitry.
kernel32: add more tests for FormatMessage{A,W}
>FormatMessage uses the same backend to find the requested resource as >FindResource does, so I'd guess that they both fail in the same way >when a resource id or a language does not exist in the module. Parsing >an actual resource data is not necessary. ok, but isn't that test already in tests/resource.c? See code snippet below: Or do i get it wrong? rsrc = FindResourceExW( GetModuleHandle(0), (LPCWSTR)RT_MENU, (LPCWSTR)MAKEINTRESOURCE(1), MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )); ok( rsrc != 0, "resource not found\n" ); rsrc = FindResourceExW( GetModuleHandle(0), (LPCWSTR)RT_MENU, (LPCWSTR)MAKEINTRESOURCE(1), MAKELANGID( LANG_GERMAN, SUBLANG_DEFAULT )); ok( rsrc != 0, "resource not found\n" ); SetLastError( 0xdeadbeef ); rsrc = FindResourceW( GetModuleHandle(0), (LPCWSTR)MAKEINTRESOURCE(1), (LPCWSTR)RT_DIALOG ); ok( !rsrc, "resource found\n" ); ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %u\n", GetLastError() ); SetLastError( 0xdeadbeef ); rsrc = FindResourceW( GetModuleHandle(0), (LPCWSTR)MAKEINTRESOURCE(2), (LPCWSTR)RT_MENU ); ok( !rsrc, "resource found\n" ); ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %u\n", GetLastError() ); SetLastError( 0xdeadbeef ); rsrc = FindResourceExW( GetModuleHandle(0), (LPCWSTR)RT_MENU, (LPCWSTR)MAKEINTRESOURCE(1), MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ) ); ok( !rsrc, "resource found\n" ); ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() ); SetLastError( 0xdeadbeef ); rsrc = FindResourceExW( GetModuleHandle(0), (LPCWSTR)RT_MENU, (LPCWSTR)MAKEINTRESOURCE(1), MAKELANGID( LANG_FRENCH, SUBLANG_DEFAULT ) ); ok( !rsrc, "resource found\n" ); ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() ); }
Re: kernel32: add more tests for FormatMessage{A,W}
"Louis Lenders" wrote: 1. There is no point in testing last error if an API didn't fail Couldn't it be that the API sets ERROR_SUCCES if it doesn't fail? That's unusual, there are APIs that do that, but they are exceptions, and it's worth to test (and fix) it only if there is an app that depends on this. 2. It would be helpful to simultaneously test return values and last error for FindResource, which should have similar behaviour (and the bug) to FormatMessage Could you explain a bit more what exactly to test? I can load the whole messagetable with FindResource from kernel32, but that always succeeds of course. FormatMessage uses the same backend to find the requested resource as FindResource does, so I'd guess that they both fail in the same way when a resource id or a language does not exist in the module. Parsing an actual resource data is not necessary. -- Dmitry.
kernel32: add more tests for FormatMessage{A,W}
>A couple of suggestions: >1. There is no point in testing last error if an API didn't fail Couldn't it be that the API sets ERROR_SUCCES if it doesn't fail? >2. It would be helpful to simultaneously test return values and >last error for FindResource, which should have similar behaviour >(and the bug) to FormatMessage Could you explain a bit more what exactly to test? I can load the whole messagetable with FindResource from kernel32, but that always succeeds of course. Using the MESSAGE_RESOURCE_BLOCK and MESSAGE_RESOURCE_ENTRY structures I could I load a messagestring I guess, but that doesn't test the behaviour of FindResource anymore. Or do i see things wrong here? Trying to load a non existing messagetable from another dll with FindResource gives ERROR_RESOURCE_TYPE_NOT_FOUND. Or is that not what you meant? >and drop FormatMessageW tests. Ok i'll do that
Re: kernel32: add more tests for FormatMessage{A,W}
"Louis Lenders" wrote: The attached tests show that this is true for "non-special" language-id's, but not for the special ones: (LANG_NEUTRAL, SUBLANG_NEUTRAL), (LANG_NEUTRAL, SUBLANG_DEFAULT),(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), and (DWORD)MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) In the latter case the error is set to ERROR_MR_MID_NOT_FOUND A couple of suggestions: 1. There is no point in testing last error if an API didn't fail 2. It would be helpful to simultaneously test return values and last error for FindResource, which should have similar behaviour (and the bug) to FormatMessage, and drop FormatMessageW tests. -- Dmitry.