Huw Davies : oledb32/tests: Add CanConvert tests.

Alexandre Julliard julliard at winehq.org
Thu Sep 17 13:53:25 CDT 2009


Module: wine
Branch: master
Commit: 5028334c9aa8f261f734e7c869a5927e9a184a67
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5028334c9aa8f261f734e7c869a5927e9a184a67

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Sep 17 14:35:25 2009 +0100

oledb32/tests: Add CanConvert tests.

---

 dlls/oledb32/tests/Makefile.in |    2 +-
 dlls/oledb32/tests/convert.c   |   76 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/dlls/oledb32/tests/Makefile.in b/dlls/oledb32/tests/Makefile.in
index f19a670..85a0ef3 100644
--- a/dlls/oledb32/tests/Makefile.in
+++ b/dlls/oledb32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = oledb32.dll
-IMPORTS   = ole32 gdi32 advapi32 kernel32
+IMPORTS   = oleaut32 ole32 gdi32 advapi32 kernel32
 
 CTESTS = \
 	convert.c
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index 8d7dd49..5ca06c3 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -144,9 +144,85 @@ static void test_dcinfo(void)
     IDCInfo_Release(info);
 }
 
+struct can_convert
+{
+    DBTYPE type;
+    DWORD can_convert_to;
+} simple_convert[] =
+{
+    {DBTYPE_EMPTY,       0x23bfd9ff},
+    {DBTYPE_NULL,        0x00001002},
+    {DBTYPE_I2,          0x3b9fd9ff},
+    {DBTYPE_I4,          0x3bdfd9ff},
+
+    {DBTYPE_R4,          0x3b9fd9ff},
+    {DBTYPE_R8,          0x3b9fd9ff},
+    {DBTYPE_CY,          0x039fd97f},
+    {DBTYPE_DATE,        0x399f99bf},
+
+    {DBTYPE_BSTR,        0x3bffd9ff},
+    {DBTYPE_IDISPATCH,   0x3bffffff},
+    {DBTYPE_ERROR,       0x01001500},
+    {DBTYPE_BOOL,        0x039fd9ff},
+
+    {DBTYPE_VARIANT,     0x3bffffff},
+    {DBTYPE_IUNKNOWN,    0x00003203},
+    {DBTYPE_DECIMAL,     0x3b9fd97f},
+    {DBTYPE_I1,          0x3b9fd9ff},
+
+    {DBTYPE_UI1,         0x3b9fd9ff},
+    {DBTYPE_UI2,         0x3b9fd9ff},
+    {DBTYPE_UI4,         0x3bdfd9ff},
+    {DBTYPE_I8,          0x03dfd97f},
+
+    {DBTYPE_UI8,         0x03dfd97f},
+    {DBTYPE_GUID,        0x01e01103},
+    {DBTYPE_BYTES,       0x01fc110b},
+    {DBTYPE_STR,         0x3bffd9ff},
+
+    {DBTYPE_WSTR,        0x3bffd9ff},
+    {DBTYPE_NUMERIC,     0x039fd97f},
+    {DBTYPE_UDT,         0x00000000},
+    {DBTYPE_DBDATE,      0x39801183},
+
+    {DBTYPE_DBTIME,      0x39801183},
+    {DBTYPE_DBTIMESTAMP, 0x39801183}
+};
+
+
+static void test_canconvert(void)
+{
+    IDataConvert *convert;
+    HRESULT hr;
+    int src_idx, dst_idx;
+
+    hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDataConvert, (void**)&convert);
+    if(FAILED(hr))
+    {
+        win_skip("Unable to load oledb conversion library\n");
+        return;
+    }
+
+    for(src_idx = 0; src_idx < sizeof(simple_convert) / sizeof(simple_convert[0]); src_idx++)
+        for(dst_idx = 0; dst_idx < sizeof(simple_convert) / sizeof(simple_convert[0]); dst_idx++)
+        {
+            BOOL expect;
+            hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type, simple_convert[dst_idx].type);
+            expect = (simple_convert[src_idx].can_convert_to >> dst_idx) & 1;
+todo_wine
+            ok((hr == S_OK && expect == TRUE) ||
+               (hr == S_FALSE && expect == FALSE),
+               "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type,
+               simple_convert[dst_idx].type, hr, expect ? "" : "not ");
+        }
+
+    IDataConvert_Release(convert);
+}
+
 START_TEST(convert)
 {
     OleInitialize(NULL);
     test_dcinfo();
+    test_canconvert();
     OleUninitialize();
 }




More information about the wine-cvs mailing list