[PATCH] mlang/tests: Add tests for Rfc1766ToLcid

Detlef Riekenberg wine.dev at web.de
Sun May 24 15:36:25 CDT 2009


---
 dlls/mlang/tests/Makefile.in |    2 +-
 dlls/mlang/tests/mlang.c     |   47 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/dlls/mlang/tests/Makefile.in b/dlls/mlang/tests/Makefile.in
index 1a5aceb..d6bd63d 100644
--- a/dlls/mlang/tests/Makefile.in
+++ b/dlls/mlang/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = mlang.dll
-IMPORTS   = oleaut32 ole32 gdi32 kernel32
+IMPORTS   = oleaut32 ole32 gdi32 kernel32 mlang
 
 CTESTS = \
 	mlang.c
diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c
index 66e80e8..a571c5c 100644
--- a/dlls/mlang/tests/mlang.c
+++ b/dlls/mlang/tests/mlang.c
@@ -928,6 +928,51 @@ static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2)
 
 }
 
+static void test_Rfc1766ToLcid(void)
+{
+    CHAR  alternateA[MAX_RFC1766_NAME + 1];
+    LCID lcid;
+    HRESULT ret;
+    DWORD i;
+
+    for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) {
+        lcid = -1;
+        ret = Rfc1766ToLcidA(&lcid, lcid_table[i].rfc1766);
+
+        if (lcid_table[i].alternate_rfc || lcid_table[i].alternate_lcid) {
+            ok(ret == S_OK || ret == S_FALSE,
+                "#%02d: HRESULT 0x%x (expected S_OK or S_FALSE)\n", i, ret);
+
+            if (ret == S_FALSE) {
+                alternateA[0] = '\0';
+
+                ret = LcidToRfc1766A(lcid, alternateA, MAX_RFC1766_NAME);
+                ok( ret == S_OK && !lstrcmpiA(alternateA, lcid_table[i].alternate_rfc),
+                    "#%02d: got 0x%x with \"%s\" (expected S_OK with %s)\n",
+                    i, ret, alternateA, lcid_table[i].alternate_rfc);
+            }
+        }
+        else
+            ok(ret == lcid_table[i].hr,
+                "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, ret, lcid_table[i].hr);
+
+        if (lcid_table[i].alternate_lcid) {
+            ok(lcid == lcid_table[i].alternate_lcid,
+                "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].alternate_lcid);
+        }
+        else
+            ok(lcid == lcid_table[i].lcid,
+                "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].lcid);
+    }
+
+    ret = Rfc1766ToLcidA(&lcid, NULL);
+    ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret);
+
+    ret = Rfc1766ToLcidA(NULL, "en");
+    ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret);
+
+}
+
 static void test_GetRfc1766FromLcid(IMultiLanguage2 *iML2)
 {
     HRESULT hr;
@@ -1514,6 +1559,8 @@ START_TEST(mlang)
         return;
 
     CoInitialize(NULL);
+    test_Rfc1766ToLcid();
+
     ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
                            &IID_IMultiLanguage2, (void **)&iML2);
     if (ret != S_OK || !iML2) return;
-- 
1.5.4.3


--=-TTD85znYa0GWXi+/Jzmq--




More information about the wine-patches mailing list