jscript: Added Object function invocation implementation.
[wine] / dlls / oledb32 / tests / convert.c
1 /* OLE DB Conversion library tests
2  *
3  * Copyright 2009 Huw Davies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include <stdarg.h>
21
22 #define COBJMACROS
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "msdadc.h"
30
31 #include "oledberr.h"
32
33 #include "initguid.h"
34 #include "msdaguid.h"
35
36 #include "wine/test.h"
37
38 static void test_dcinfo(void)
39 {
40     IDCInfo *info;
41     HRESULT hr;
42     DCINFOTYPE types[2];
43     DCINFO *inf;
44
45     hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDCInfo, (void**)&info);
46     if(FAILED(hr))
47     {
48         win_skip("Unable to load oledb conversion library\n");
49         return;
50     }
51
52     types[0] = DCINFOTYPE_VERSION;
53     hr = IDCInfo_GetInfo(info, 1, types, &inf);
54     ok(hr == S_OK, "got %08x\n", hr);
55
56     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
57     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
58     ok(V_UI4(&inf->vData) == 0x110, "got %08x\n", V_UI4(&inf->vData));
59
60     V_UI4(&inf->vData) = 0x200;
61     hr = IDCInfo_SetInfo(info, 1, inf);
62     ok(hr == S_OK, "got %08x\n", hr);
63     CoTaskMemFree(inf);
64
65     hr = IDCInfo_GetInfo(info, 1, types, &inf);
66     ok(hr == S_OK, "got %08x\n", hr);
67     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
68     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
69     ok(V_UI4(&inf->vData) == 0x200, "got %08x\n", V_UI4(&inf->vData));
70
71     V_UI4(&inf->vData) = 0x100;
72     hr = IDCInfo_SetInfo(info, 1, inf);
73     ok(hr == S_OK, "got %08x\n", hr);
74     CoTaskMemFree(inf);
75
76     hr = IDCInfo_GetInfo(info, 1, types, &inf);
77     ok(hr == S_OK, "got %08x\n", hr);
78     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
79     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
80     ok(V_UI4(&inf->vData) == 0x100, "got %08x\n", V_UI4(&inf->vData));
81
82     V_UI4(&inf->vData) = 0x500;
83     hr = IDCInfo_SetInfo(info, 1, inf);
84     ok(hr == S_OK, "got %08x\n", hr);
85     CoTaskMemFree(inf);
86
87     hr = IDCInfo_GetInfo(info, 1, types, &inf);
88     ok(hr == S_OK, "got %08x\n", hr);
89     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
90     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
91     ok(V_UI4(&inf->vData) == 0x500, "got %08x\n", V_UI4(&inf->vData));
92
93     V_UI4(&inf->vData) = 0xffff;
94     hr = IDCInfo_SetInfo(info, 1, inf);
95     ok(hr == S_OK, "got %08x\n", hr);
96     CoTaskMemFree(inf);
97
98     hr = IDCInfo_GetInfo(info, 1, types, &inf);
99     ok(hr == S_OK, "got %08x\n", hr);
100     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
101     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
102     ok(V_UI4(&inf->vData) == 0xffff, "got %08x\n", V_UI4(&inf->vData));
103
104     V_UI4(&inf->vData) = 0x12345678;
105     hr = IDCInfo_SetInfo(info, 1, inf);
106     ok(hr == S_OK, "got %08x\n", hr);
107     CoTaskMemFree(inf);
108
109     hr = IDCInfo_GetInfo(info, 1, types, &inf);
110     ok(hr == S_OK, "got %08x\n", hr);
111     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
112     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
113     ok(V_UI4(&inf->vData) == 0x12345678, "got %08x\n", V_UI4(&inf->vData));
114
115     /* Try setting a version variant of something other than VT_UI4 */
116     V_VT(&inf->vData) = VT_I4;
117     V_I4(&inf->vData) = 0x200;
118     hr = IDCInfo_SetInfo(info, 1, inf);
119     ok(hr == DB_S_ERRORSOCCURRED, "got %08x\n", hr);
120     CoTaskMemFree(inf);
121
122     hr = IDCInfo_GetInfo(info, 1, types, &inf);
123     ok(hr == S_OK, "got %08x\n", hr);
124     ok(inf->eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf->eInfoType);
125     ok(V_VT(&inf->vData) == VT_UI4, "got %08x\n", V_VT(&inf->vData));
126     ok(V_UI4(&inf->vData) == 0x12345678, "got %08x\n", V_UI4(&inf->vData));
127     CoTaskMemFree(inf);
128
129     /* More than one type */
130     types[1] = 2;
131     hr = IDCInfo_GetInfo(info, 2, types, &inf);
132     ok(hr == S_OK, "got %08x\n", hr);
133     ok(inf[0].eInfoType == DCINFOTYPE_VERSION, "got %08x\n", inf[0].eInfoType);
134     ok(V_VT(&inf[0].vData) == VT_UI4, "got %08x\n", V_VT(&inf[0].vData));
135     ok(V_UI4(&inf[0].vData) == 0x12345678, "got %08x\n", V_UI4(&inf[0].vData));
136     ok(inf[1].eInfoType == 2, "got %08x\n", inf[1].eInfoType);
137     ok(V_VT(&inf[1].vData) == VT_EMPTY, "got %08x\n", V_VT(&inf[1].vData));
138
139     hr = IDCInfo_SetInfo(info, 2, inf);
140     ok(hr == S_OK, "got %08x\n", hr);
141     CoTaskMemFree(inf);
142
143
144     IDCInfo_Release(info);
145 }
146
147 START_TEST(convert)
148 {
149     OleInitialize(NULL);
150     test_dcinfo();
151     OleUninitialize();
152 }