kernel32: Correct WideCharToMultiByte and MultiByteToWideChar error codes and conditions (try 4)

Juan Lang juan.lang at gmail.com
Thu May 10 10:19:37 CDT 2012


Hi Alex,
first, thanks for taking the time to respond to feedback.  Showing
responsiveness helps a great deal.

Next, on your patch: I'm trying to help you get this committed, so
this is meant to be constructive feedback.

+static void test_WideCharToMultiByte_error(UINT page, DWORD flags, LPCWSTR src,
+                                           INT srclen, LPSTR dst, INT dstlen,
+                                           LPCSTR defchar, BOOL* used,
+                                           const char* test_description,
+                                           DWORD expected_error)
+{
+    SetLastError(ERROR_SUCCESS);
+    WideCharToMultiByte(page, flags, src, srclen, dst, dstlen, defchar, used);
+    ok(GetLastError() == expected_error,
+       "codepage %i, %s, expected error %i got error %i\n", page,
+       test_description, expected_error, GetLastError());
+}
+
+static void test_MultiByteToWideChar_error(UINT page, DWORD flags, LPCSTR src,
+                                           INT srclen, LPWSTR dst, INT dstlen,
+                                           const char* test_description,
+                                           DWORD expected_error)
+{
+    SetLastError(ERROR_SUCCESS);
+    MultiByteToWideChar(page, flags, src, srclen, dst, dstlen);
+    ok(GetLastError() == expected_error,
+       "codepage %i, %s, expected error %i got error %i\n", page,
+       test_description, expected_error, GetLastError());
+}

These helpers don't really gain you anything here, there's really not
enough code to be worth using helpers.  Please just copy/paste the
changes everyplace you're currently using them.  Also, a common
convention we use is to set last error to 0xdeadbeef prior to a test
we expect to set last error on failure.

Thanks,
--Juan



More information about the wine-devel mailing list