2 * Low level variant tests
4 * Copyright 2003 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
32 DEFINE_GUID(UUID_test_struct
, 0x4029f190, 0xca4a, 0x4611, 0xae,0xb9,0x67,0x39,0x83,0xcb,0x96,0xdd);
34 /* Some Visual C++ versions choke on __uint64 to float conversions.
35 * To fix this you need either VC++ 6.0 plus the processor pack
36 * or Visual C++ >=7.0.
39 # define HAS_UINT64_TO_FLOAT
42 # define HAS_UINT64_TO_FLOAT
45 # if defined(_mm_free)
46 /* _mm_free is defined if the Processor Pack has been installed */
47 # define HAS_UINT64_TO_FLOAT
53 static HMODULE hOleaut32
;
55 /* Get a conversion function ptr, return if function not available */
56 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
58 win_skip("function " # func " not available, not testing it\n"); return; }
60 /* Has I8/UI8 data type? */
62 /* Has proper locale conversions? */
63 static BOOL has_locales
;
65 /* Is vt a type unavailable to ancient versions? */
66 #define IS_MODERN_VTYPE(vt) (vt==VT_VARIANT||vt==VT_DECIMAL|| \
67 vt==VT_I1||vt==VT_UI2||vt==VT_UI4||vt == VT_INT||vt == VT_UINT)
69 /* Macros for converting and testing results */
70 #define CONVVARS(typ) HRESULT hres; CONV_TYPE out; typ in
72 #define _EXPECT_NO_OUT(res) ok(hres == res, "expected " #res ", got hres=0x%08x\n", hres)
73 #define EXPECT_OVERFLOW _EXPECT_NO_OUT(DISP_E_OVERFLOW)
74 #define EXPECT_MISMATCH _EXPECT_NO_OUT(DISP_E_TYPEMISMATCH)
75 #define EXPECT_BADVAR _EXPECT_NO_OUT(DISP_E_BADVARTYPE)
76 #define EXPECT_INVALID _EXPECT_NO_OUT(E_INVALIDARG)
77 #define EXPECT_LT _EXPECT_NO_OUT(VARCMP_LT)
78 #define EXPECT_GT _EXPECT_NO_OUT(VARCMP_GT)
79 #define EXPECT_EQ _EXPECT_NO_OUT(VARCMP_EQ)
81 #define _EXPECTRES(res, x, fs) \
82 ok(hres == S_OK && out == (CONV_TYPE)(x), "expected " #x ", got " fs "; hres=0x%08x\n", out, hres)
83 #define EXPECT(x) EXPECTRES(S_OK, (x))
84 #define EXPECT_DBL(x) \
85 ok(hres == S_OK && fabs(out-(x))<=1e-14*(x), "expected %16.16g, got %16.16g; hres=0x%08x\n", (x), out, hres)
87 #define CONVERT(func, val) in = val; hres = p##func(in, &out)
88 #define CONVERTRANGE(func,start,end) for (i = start; i < end; i+=1) { CONVERT(func, i); EXPECT(i); };
89 #define OVERFLOWRANGE(func,start,end) for (i = start; i < end; i+=1) { CONVERT(func, i); EXPECT_OVERFLOW; };
91 #define CY_MULTIPLIER 10000
93 #define DATE_MIN -657434
94 #define DATE_MAX 2958465
96 #define CONVERT_I8(func,hi,lo) in = hi; in = (in << 32) | lo; hres = p##func(in, &out)
98 #define CONVERT_CY(func,val) in.int64 = (LONGLONG)(val * CY_MULTIPLIER); hres = p##func(in, &out)
100 #define CONVERT_CY64(func,hi,lo) S(in).Hi = hi; S(in).Lo = lo; in.int64 *= CY_MULTIPLIER; hres = p##func(in, &out)
102 #define SETDEC(dec, scl, sgn, hi, lo) S(U(dec)).scale = (BYTE)scl; S(U(dec)).sign = (BYTE)sgn; \
103 dec.Hi32 = (ULONG)hi; U1(dec).Lo64 = (ULONG64)lo
105 #define SETDEC64(dec, scl, sgn, hi, mid, lo) S(U(dec)).scale = (BYTE)scl; S(U(dec)).sign = (BYTE)sgn; \
106 dec.Hi32 = (ULONG)hi; S1(U1(dec)).Mid32 = mid; S1(U1(dec)).Lo32 = lo;
108 #define CONVERT_DEC(func,scl,sgn,hi,lo) SETDEC(in,scl,sgn,hi,lo); hres = p##func(&in, &out)
110 #define CONVERT_DEC64(func,scl,sgn,hi,mid,lo) SETDEC64(in,scl,sgn,hi,mid,lo); hres = p##func(&in, &out)
112 #define CONVERT_BADDEC(func) \
113 CONVERT_DEC(func,29,0,0,0); EXPECT_INVALID; \
114 CONVERT_DEC(func,0,0x1,0,0); EXPECT_INVALID; \
115 CONVERT_DEC(func,0,0x40,0,0); EXPECT_INVALID; \
116 CONVERT_DEC(func,0,0x7f,0,0); EXPECT_INVALID;
118 #define CONVERT_STR(func,str,flags) \
120 if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
121 hres = p##func(str ? buff : NULL,in,flags,&out)
123 #define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \
124 HRESULT hres; VARIANTARG vSrc, vDst; CONV_TYPE in = val; \
125 VariantInit(&vSrc); VariantInit(&vDst); \
126 V_VT(&vSrc) = vt; srcval = in; \
127 hres = VariantCopy(&vDst, &vSrc); \
128 ok(hres == S_OK && V_VT(&vDst) == vt && dstval == in, \
129 "copy hres 0x%X, type %d, value (" fs ") " fs "\n", hres, V_VT(&vDst), val, dstval); \
130 V_VT(&vSrc) = vt|VT_BYREF; srcref = ∈ \
131 hres = VariantCopy(&vDst, &vSrc); \
132 ok(hres == S_OK && V_VT(&vDst) == (vt|VT_BYREF) && dstref == &in, \
133 "ref hres 0x%X, type %d, ref (%p) %p\n", hres, V_VT(&vDst), &in, dstref); \
134 hres = VariantCopyInd(&vDst, &vSrc); \
135 ok(hres == S_OK && V_VT(&vDst) == vt && dstval == in, \
136 "ind hres 0x%X, type %d, value (" fs ") " fs "\n", hres, V_VT(&vDst), val, dstval); \
139 #define CHANGETYPEEX(typ) hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, typ)
141 #define TYPETEST(typ,res,fs) CHANGETYPEEX(typ); \
142 ok(hres == S_OK && V_VT(&vDst) == typ && (CONV_TYPE)res == in, \
143 "hres=0x%X, type=%d (should be %d(" #typ ")), value=" fs " (should be " fs ")\n", \
144 hres, V_VT(&vDst), typ, (CONV_TYPE)res, in);
145 #define TYPETESTI8(typ,res) CHANGETYPEEX(typ); \
146 ok(hres == S_OK && V_VT(&vDst) == typ && (CONV_TYPE)res == in, \
147 "hres=0x%X, type=%d (should be %d(" #typ ")), value=%d (should be 1)\n", \
148 hres, V_VT(&vDst), typ, (int)res);
149 #define BADVAR(typ) CHANGETYPEEX(typ); EXPECT_BADVAR
150 #define MISMATCH(typ) CHANGETYPEEX(typ); EXPECT_MISMATCH
152 #define INITIAL_TYPETEST(vt, val, fs) \
153 VariantInit(&vSrc); \
154 VariantInit(&vDst); \
157 TYPETEST(VT_I1, V_I1(&vDst), fs); \
158 TYPETEST(VT_UI2, V_UI2(&vDst), fs); \
159 TYPETEST(VT_UI4, V_UI4(&vDst), fs); \
160 TYPETEST(VT_INT, V_INT(&vDst), fs); \
161 TYPETEST(VT_UINT, V_UINT(&vDst), fs); \
162 TYPETEST(VT_UI1, V_UI1(&vDst), fs); \
163 TYPETEST(VT_I2, V_I2(&vDst), fs); \
164 TYPETEST(VT_I4, V_I4(&vDst), fs); \
165 TYPETEST(VT_R4, V_R4(&vDst), fs); \
166 TYPETEST(VT_R8, V_R8(&vDst), fs); \
167 TYPETEST(VT_DATE, V_DATE(&vDst), fs); \
170 TYPETEST(VT_I8, V_I8(&vDst), fs); \
171 TYPETEST(VT_UI8, V_UI8(&vDst), fs); \
173 #define NEGATIVE_TYPETEST(vt, val, fs, vtneg, valneg) \
175 VariantInit(&vSrc); \
176 VariantInit(&vDst); \
179 TYPETEST(vtneg, valneg(&vDst), fs);
181 #define INITIAL_TYPETESTI8(vt, val) \
182 VariantInit(&vSrc); \
183 VariantInit(&vDst); \
186 TYPETESTI8(VT_I1, V_I1(&vDst)); \
187 TYPETESTI8(VT_UI1, V_UI1(&vDst)); \
188 TYPETESTI8(VT_I2, V_I2(&vDst)); \
189 TYPETESTI8(VT_UI2, V_UI2(&vDst)); \
190 TYPETESTI8(VT_I4, V_I4(&vDst)); \
191 TYPETESTI8(VT_UI4, V_UI4(&vDst)); \
192 TYPETESTI8(VT_INT, V_INT(&vDst)); \
193 TYPETESTI8(VT_UINT, V_UINT(&vDst)); \
194 TYPETESTI8(VT_R4, V_R4(&vDst)); \
195 TYPETESTI8(VT_R8, V_R8(&vDst)); \
196 TYPETESTI8(VT_DATE, V_DATE(&vDst)); \
197 TYPETESTI8(VT_I8, V_I8(&vDst)); \
198 TYPETESTI8(VT_UI8, V_UI8(&vDst))
200 #define COMMON_TYPETEST \
201 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_BOOL); \
202 ok(hres == S_OK && V_VT(&vDst) == VT_BOOL && \
203 (V_BOOL(&vDst) == VARIANT_TRUE || (V_VT(&vSrc) == VT_BOOL && V_BOOL(&vDst) == 1)), \
204 "->VT_BOOL hres=0x%X, type=%d (should be VT_BOOL), value %d (should be VARIANT_TRUE)\n", \
205 hres, V_VT(&vDst), V_BOOL(&vDst)); \
206 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_CY); \
207 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == CY_MULTIPLIER, \
208 "->VT_CY hres=0x%X, type=%d (should be VT_CY), value (%08x,%08x) (should be CY_MULTIPLIER)\n", \
209 hres, V_VT(&vDst), S(V_CY(&vDst)).Hi, S(V_CY(&vDst)).Lo); \
210 if (V_VT(&vSrc) != VT_DATE) \
212 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_BSTR); \
213 ok(hres == S_OK && V_VT(&vDst) == VT_BSTR && \
214 V_BSTR(&vDst) && V_BSTR(&vDst)[0] == '1' && V_BSTR(&vDst)[1] == '\0', \
215 "->VT_BSTR hres=0x%X, type=%d (should be VT_BSTR), *bstr='%c'\n", \
216 hres, V_VT(&vDst), V_BSTR(&vDst) ? *V_BSTR(&vDst) : '?'); \
218 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_DECIMAL); \
219 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && \
220 S(U(V_DECIMAL(&vDst))).sign == 0 && S(U(V_DECIMAL(&vDst))).scale == 0 && \
221 V_DECIMAL(&vDst).Hi32 == 0 && U1(V_DECIMAL(&vDst)).Lo64 == (ULONGLONG)in, \
222 "->VT_DECIMAL hres=0x%X, type=%d (should be VT_DECIMAL), sign=%d, scale=%d, hi=%u, lo=(%8x %8x),\n", \
223 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign, S(U(V_DECIMAL(&vDst))).scale, \
224 V_DECIMAL(&vDst).Hi32, S1(U1(V_DECIMAL(&vDst))).Mid32, S1(U1(V_DECIMAL(&vDst))).Lo32); \
225 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_EMPTY); \
226 ok(hres == S_OK && V_VT(&vDst) == VT_EMPTY, "->VT_EMPTY hres=0x%X, type=%d (should be VT_EMPTY)\n", hres, V_VT(&vDst)); \
227 hres = VariantChangeTypeEx(&vDst, &vSrc, 0, 0, VT_NULL); \
228 ok(hres == S_OK && V_VT(&vDst) == VT_NULL, "->VT_NULL hres=0x%X, type=%d (should be VT_NULL)\n", hres, V_VT(&vDst)); \
229 MISMATCH(VT_DISPATCH); \
230 MISMATCH(VT_ERROR); \
231 MISMATCH(VT_UNKNOWN); \
232 MISMATCH(VT_VARIANT); \
233 MISMATCH(VT_RECORD); \
235 BADVAR(VT_HRESULT); \
236 BADVAR(VT_SAFEARRAY); \
238 BADVAR(VT_USERDEFINED); \
242 BADVAR(VT_INT_PTR); \
243 BADVAR(VT_UINT_PTR); \
244 BADVAR(VT_FILETIME); \
247 BADVAR(VT_STORAGE); \
248 BADVAR(VT_STREAMED_OBJECT); \
249 BADVAR(VT_STORED_OBJECT); \
250 BADVAR(VT_BLOB_OBJECT); \
255 #define DEFINE_EXPECT(func) \
256 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
258 #define SET_EXPECT(func) \
259 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
261 #define CHECK_EXPECT2(func) \
263 ok(expect_ ##func, "unexpected call " #func "\n"); \
264 called_ ## func = TRUE; \
267 #define CHECK_EXPECT(func) \
269 CHECK_EXPECT2(func); \
270 expect_ ## func = FALSE; \
273 #define CHECK_CALLED(func) \
275 ok(called_ ## func, "expected " #func "\n"); \
276 expect_ ## func = called_ ## func = FALSE; \
279 DEFINE_EXPECT(dispatch_invoke
);
281 /* Early versions of oleaut32 are missing many functions */
282 static HRESULT (WINAPI
*pVarI1FromUI1
)(BYTE
,signed char*);
283 static HRESULT (WINAPI
*pVarI1FromI2
)(SHORT
,signed char*);
284 static HRESULT (WINAPI
*pVarI1FromI4
)(LONG
,signed char*);
285 static HRESULT (WINAPI
*pVarI1FromR4
)(FLOAT
,signed char*);
286 static HRESULT (WINAPI
*pVarI1FromR8
)(double,signed char*);
287 static HRESULT (WINAPI
*pVarI1FromDate
)(DATE
,signed char*);
288 static HRESULT (WINAPI
*pVarI1FromCy
)(CY
,signed char*);
289 static HRESULT (WINAPI
*pVarI1FromStr
)(OLECHAR
*,LCID
,ULONG
,signed char*);
290 static HRESULT (WINAPI
*pVarI1FromBool
)(VARIANT_BOOL
,signed char*);
291 static HRESULT (WINAPI
*pVarI1FromUI2
)(USHORT
,signed char*);
292 static HRESULT (WINAPI
*pVarI1FromUI4
)(ULONG
,signed char*);
293 static HRESULT (WINAPI
*pVarI1FromDec
)(DECIMAL
*,signed char*);
294 static HRESULT (WINAPI
*pVarI1FromI8
)(LONG64
,signed char*);
295 static HRESULT (WINAPI
*pVarI1FromUI8
)(ULONG64
,signed char*);
296 static HRESULT (WINAPI
*pVarUI1FromI2
)(SHORT
,BYTE
*);
297 static HRESULT (WINAPI
*pVarUI1FromI4
)(LONG
,BYTE
*);
298 static HRESULT (WINAPI
*pVarUI1FromR4
)(FLOAT
,BYTE
*);
299 static HRESULT (WINAPI
*pVarUI1FromR8
)(double,BYTE
*);
300 static HRESULT (WINAPI
*pVarUI1FromCy
)(CY
,BYTE
*);
301 static HRESULT (WINAPI
*pVarUI1FromDate
)(DATE
,BYTE
*);
302 static HRESULT (WINAPI
*pVarUI1FromStr
)(OLECHAR
*,LCID
,ULONG
,BYTE
*);
303 static HRESULT (WINAPI
*pVarUI1FromBool
)(VARIANT_BOOL
,BYTE
*);
304 static HRESULT (WINAPI
*pVarUI1FromI1
)(signed char,BYTE
*);
305 static HRESULT (WINAPI
*pVarUI1FromUI2
)(USHORT
,BYTE
*);
306 static HRESULT (WINAPI
*pVarUI1FromUI4
)(ULONG
,BYTE
*);
307 static HRESULT (WINAPI
*pVarUI1FromDec
)(DECIMAL
*,BYTE
*);
308 static HRESULT (WINAPI
*pVarUI1FromI8
)(LONG64
,BYTE
*);
309 static HRESULT (WINAPI
*pVarUI1FromUI8
)(ULONG64
,BYTE
*);
310 static HRESULT (WINAPI
*pVarUI1FromDisp
)(IDispatch
*,LCID
,BYTE
*);
312 static HRESULT (WINAPI
*pVarI2FromUI1
)(BYTE
,SHORT
*);
313 static HRESULT (WINAPI
*pVarI2FromI4
)(LONG
,SHORT
*);
314 static HRESULT (WINAPI
*pVarI2FromR4
)(FLOAT
,SHORT
*);
315 static HRESULT (WINAPI
*pVarI2FromR8
)(double,SHORT
*);
316 static HRESULT (WINAPI
*pVarI2FromCy
)(CY
,SHORT
*);
317 static HRESULT (WINAPI
*pVarI2FromDate
)(DATE
,SHORT
*);
318 static HRESULT (WINAPI
*pVarI2FromStr
)(OLECHAR
*,LCID
,ULONG
,SHORT
*);
319 static HRESULT (WINAPI
*pVarI2FromBool
)(VARIANT_BOOL
,SHORT
*);
320 static HRESULT (WINAPI
*pVarI2FromI1
)(signed char,SHORT
*);
321 static HRESULT (WINAPI
*pVarI2FromUI2
)(USHORT
,SHORT
*);
322 static HRESULT (WINAPI
*pVarI2FromUI4
)(ULONG
,SHORT
*);
323 static HRESULT (WINAPI
*pVarI2FromDec
)(DECIMAL
*,SHORT
*);
324 static HRESULT (WINAPI
*pVarI2FromI8
)(LONG64
,SHORT
*);
325 static HRESULT (WINAPI
*pVarI2FromUI8
)(ULONG64
,SHORT
*);
326 static HRESULT (WINAPI
*pVarUI2FromUI1
)(BYTE
,USHORT
*);
327 static HRESULT (WINAPI
*pVarUI2FromI2
)(SHORT
,USHORT
*);
328 static HRESULT (WINAPI
*pVarUI2FromI4
)(LONG
,USHORT
*);
329 static HRESULT (WINAPI
*pVarUI2FromR4
)(FLOAT
,USHORT
*);
330 static HRESULT (WINAPI
*pVarUI2FromR8
)(double,USHORT
*);
331 static HRESULT (WINAPI
*pVarUI2FromDate
)(DATE
,USHORT
*);
332 static HRESULT (WINAPI
*pVarUI2FromCy
)(CY
,USHORT
*);
333 static HRESULT (WINAPI
*pVarUI2FromStr
)(OLECHAR
*,LCID
,ULONG
,USHORT
*);
334 static HRESULT (WINAPI
*pVarUI2FromBool
)(VARIANT_BOOL
,USHORT
*);
335 static HRESULT (WINAPI
*pVarUI2FromI1
)(signed char,USHORT
*);
336 static HRESULT (WINAPI
*pVarUI2FromUI4
)(ULONG
,USHORT
*);
337 static HRESULT (WINAPI
*pVarUI2FromDec
)(DECIMAL
*,USHORT
*);
338 static HRESULT (WINAPI
*pVarUI2FromI8
)(LONG64
,USHORT
*);
339 static HRESULT (WINAPI
*pVarUI2FromUI8
)(ULONG64
,USHORT
*);
341 static HRESULT (WINAPI
*pVarI4FromUI1
)(BYTE
,LONG
*);
342 static HRESULT (WINAPI
*pVarI4FromI2
)(SHORT
,LONG
*);
343 static HRESULT (WINAPI
*pVarI4FromR4
)(FLOAT
,LONG
*);
344 static HRESULT (WINAPI
*pVarI4FromR8
)(DOUBLE
,LONG
*);
345 static HRESULT (WINAPI
*pVarI4FromCy
)(CY
,LONG
*);
346 static HRESULT (WINAPI
*pVarI4FromDate
)(DATE
,LONG
*);
347 static HRESULT (WINAPI
*pVarI4FromStr
)(OLECHAR
*,LCID
,ULONG
,LONG
*);
348 static HRESULT (WINAPI
*pVarI4FromBool
)(VARIANT_BOOL
,LONG
*);
349 static HRESULT (WINAPI
*pVarI4FromI1
)(signed char,LONG
*);
350 static HRESULT (WINAPI
*pVarI4FromUI2
)(USHORT
,LONG
*);
351 static HRESULT (WINAPI
*pVarI4FromUI4
)(ULONG
,LONG
*);
352 static HRESULT (WINAPI
*pVarI4FromDec
)(DECIMAL
*,LONG
*);
353 static HRESULT (WINAPI
*pVarI4FromI8
)(LONG64
,LONG
*);
354 static HRESULT (WINAPI
*pVarI4FromUI8
)(ULONG64
,LONG
*);
355 static HRESULT (WINAPI
*pVarUI4FromUI1
)(BYTE
,ULONG
*);
356 static HRESULT (WINAPI
*pVarUI4FromI2
)(SHORT
,ULONG
*);
357 static HRESULT (WINAPI
*pVarUI4FromI4
)(LONG
,ULONG
*);
358 static HRESULT (WINAPI
*pVarUI4FromR4
)(FLOAT
,ULONG
*);
359 static HRESULT (WINAPI
*pVarUI4FromR8
)(DOUBLE
,ULONG
*);
360 static HRESULT (WINAPI
*pVarUI4FromDate
)(DATE
,ULONG
*);
361 static HRESULT (WINAPI
*pVarUI4FromCy
)(CY
,ULONG
*);
362 static HRESULT (WINAPI
*pVarUI4FromStr
)(OLECHAR
*,LCID
,ULONG
,ULONG
*);
363 static HRESULT (WINAPI
*pVarUI4FromBool
)(VARIANT_BOOL
,ULONG
*);
364 static HRESULT (WINAPI
*pVarUI4FromI1
)(signed char,ULONG
*);
365 static HRESULT (WINAPI
*pVarUI4FromUI2
)(USHORT
,ULONG
*);
366 static HRESULT (WINAPI
*pVarUI4FromDec
)(DECIMAL
*,ULONG
*);
367 static HRESULT (WINAPI
*pVarUI4FromI8
)(LONG64
,ULONG
*);
368 static HRESULT (WINAPI
*pVarUI4FromUI8
)(ULONG64
,ULONG
*);
370 static HRESULT (WINAPI
*pVarI8FromUI1
)(BYTE
,LONG64
*);
371 static HRESULT (WINAPI
*pVarI8FromI2
)(SHORT
,LONG64
*);
372 static HRESULT (WINAPI
*pVarI8FromR4
)(FLOAT
,LONG64
*);
373 static HRESULT (WINAPI
*pVarI8FromR8
)(double,LONG64
*);
374 static HRESULT (WINAPI
*pVarI8FromCy
)(CY
,LONG64
*);
375 static HRESULT (WINAPI
*pVarI8FromDate
)(DATE
,LONG64
*);
376 static HRESULT (WINAPI
*pVarI8FromStr
)(OLECHAR
*,LCID
,ULONG
,LONG64
*);
377 static HRESULT (WINAPI
*pVarI8FromBool
)(VARIANT_BOOL
,LONG64
*);
378 static HRESULT (WINAPI
*pVarI8FromI1
)(signed char,LONG64
*);
379 static HRESULT (WINAPI
*pVarI8FromUI2
)(USHORT
,LONG64
*);
380 static HRESULT (WINAPI
*pVarI8FromUI4
)(ULONG
,LONG64
*);
381 static HRESULT (WINAPI
*pVarI8FromDec
)(DECIMAL
*,LONG64
*);
382 static HRESULT (WINAPI
*pVarI8FromUI8
)(ULONG64
,LONG64
*);
383 static HRESULT (WINAPI
*pVarUI8FromI8
)(LONG64
,ULONG64
*);
384 static HRESULT (WINAPI
*pVarUI8FromUI1
)(BYTE
,ULONG64
*);
385 static HRESULT (WINAPI
*pVarUI8FromI2
)(SHORT
,ULONG64
*);
386 static HRESULT (WINAPI
*pVarUI8FromR4
)(FLOAT
,ULONG64
*);
387 static HRESULT (WINAPI
*pVarUI8FromR8
)(double,ULONG64
*);
388 static HRESULT (WINAPI
*pVarUI8FromCy
)(CY
,ULONG64
*);
389 static HRESULT (WINAPI
*pVarUI8FromDate
)(DATE
,ULONG64
*);
390 static HRESULT (WINAPI
*pVarUI8FromStr
)(OLECHAR
*,LCID
,ULONG
,ULONG64
*);
391 static HRESULT (WINAPI
*pVarUI8FromBool
)(VARIANT_BOOL
,ULONG64
*);
392 static HRESULT (WINAPI
*pVarUI8FromI1
)(signed char,ULONG64
*);
393 static HRESULT (WINAPI
*pVarUI8FromUI2
)(USHORT
,ULONG64
*);
394 static HRESULT (WINAPI
*pVarUI8FromUI4
)(ULONG
,ULONG64
*);
395 static HRESULT (WINAPI
*pVarUI8FromDec
)(DECIMAL
*,ULONG64
*);
397 static HRESULT (WINAPI
*pVarR4FromUI1
)(BYTE
,float*);
398 static HRESULT (WINAPI
*pVarR4FromI2
)(SHORT
,float*);
399 static HRESULT (WINAPI
*pVarR4FromI4
)(LONG
,float*);
400 static HRESULT (WINAPI
*pVarR4FromR8
)(double,float*);
401 static HRESULT (WINAPI
*pVarR4FromCy
)(CY
,float*);
402 static HRESULT (WINAPI
*pVarR4FromDate
)(DATE
,float*);
403 static HRESULT (WINAPI
*pVarR4FromStr
)(OLECHAR
*,LCID
,ULONG
,float*);
404 static HRESULT (WINAPI
*pVarR4FromBool
)(VARIANT_BOOL
,float*);
405 static HRESULT (WINAPI
*pVarR4FromI1
)(signed char,float*);
406 static HRESULT (WINAPI
*pVarR4FromUI2
)(USHORT
,float*);
407 static HRESULT (WINAPI
*pVarR4FromUI4
)(ULONG
,float*);
408 static HRESULT (WINAPI
*pVarR4FromDec
)(DECIMAL
*,float*);
409 static HRESULT (WINAPI
*pVarR4FromI8
)(LONG64
,float*);
410 static HRESULT (WINAPI
*pVarR4FromUI8
)(ULONG64
,float*);
412 static HRESULT (WINAPI
*pVarR8FromUI1
)(BYTE
,double*);
413 static HRESULT (WINAPI
*pVarR8FromI2
)(SHORT
,double*);
414 static HRESULT (WINAPI
*pVarR8FromI4
)(LONG
,double*);
415 static HRESULT (WINAPI
*pVarR8FromR4
)(FLOAT
,double*);
416 static HRESULT (WINAPI
*pVarR8FromCy
)(CY
,double*);
417 static HRESULT (WINAPI
*pVarR8FromDate
)(DATE
,double*);
418 static HRESULT (WINAPI
*pVarR8FromStr
)(OLECHAR
*,LCID
,ULONG
,double*);
419 static HRESULT (WINAPI
*pVarR8FromBool
)(VARIANT_BOOL
,double*);
420 static HRESULT (WINAPI
*pVarR8FromI1
)(signed char,double*);
421 static HRESULT (WINAPI
*pVarR8FromUI2
)(USHORT
,double*);
422 static HRESULT (WINAPI
*pVarR8FromUI4
)(ULONG
,double*);
423 static HRESULT (WINAPI
*pVarR8FromDec
)(DECIMAL
*,double*);
424 static HRESULT (WINAPI
*pVarR8FromI8
)(LONG64
,double*);
425 static HRESULT (WINAPI
*pVarR8FromUI8
)(ULONG64
,double*);
426 static HRESULT (WINAPI
*pVarR8Round
)(double,int,double*);
428 static HRESULT (WINAPI
*pVarDateFromUI1
)(BYTE
,DATE
*);
429 static HRESULT (WINAPI
*pVarDateFromI2
)(SHORT
,DATE
*);
430 static HRESULT (WINAPI
*pVarDateFromI4
)(LONG
,DATE
*);
431 static HRESULT (WINAPI
*pVarDateFromR4
)(FLOAT
,DATE
*);
432 static HRESULT (WINAPI
*pVarDateFromCy
)(CY
,DATE
*);
433 static HRESULT (WINAPI
*pVarDateFromR8
)(double,DATE
*);
434 static HRESULT (WINAPI
*pVarDateFromStr
)(OLECHAR
*,LCID
,ULONG
,DATE
*);
435 static HRESULT (WINAPI
*pVarDateFromBool
)(VARIANT_BOOL
,DATE
*);
436 static HRESULT (WINAPI
*pVarDateFromI1
)(signed char,DATE
*);
437 static HRESULT (WINAPI
*pVarDateFromUI2
)(USHORT
,DATE
*);
438 static HRESULT (WINAPI
*pVarDateFromUI4
)(ULONG
,DATE
*);
439 static HRESULT (WINAPI
*pVarDateFromDec
)(DECIMAL
*,DATE
*);
440 static HRESULT (WINAPI
*pVarDateFromI8
)(LONG64
,DATE
*);
441 static HRESULT (WINAPI
*pVarDateFromUI8
)(ULONG64
,DATE
*);
443 static HRESULT (WINAPI
*pVarCyFromUI1
)(BYTE
,CY
*);
444 static HRESULT (WINAPI
*pVarCyFromI2
)(SHORT
,CY
*);
445 static HRESULT (WINAPI
*pVarCyFromI4
)(LONG
,CY
*);
446 static HRESULT (WINAPI
*pVarCyFromR4
)(FLOAT
,CY
*);
447 static HRESULT (WINAPI
*pVarCyFromR8
)(double,CY
*);
448 static HRESULT (WINAPI
*pVarCyFromDate
)(DATE
,CY
*);
449 static HRESULT (WINAPI
*pVarCyFromBool
)(VARIANT_BOOL
,CY
*);
450 static HRESULT (WINAPI
*pVarCyFromI1
)(signed char,CY
*);
451 static HRESULT (WINAPI
*pVarCyFromUI2
)(USHORT
,CY
*);
452 static HRESULT (WINAPI
*pVarCyFromUI4
)(ULONG
,CY
*);
453 static HRESULT (WINAPI
*pVarCyFromDec
)(DECIMAL
*,CY
*);
454 static HRESULT (WINAPI
*pVarCyFromI8
)(LONG64
,CY
*);
455 static HRESULT (WINAPI
*pVarCyFromUI8
)(ULONG64
,CY
*);
456 static HRESULT (WINAPI
*pVarCyAdd
)(const CY
,const CY
,CY
*);
457 static HRESULT (WINAPI
*pVarCyMul
)(const CY
,const CY
,CY
*);
458 static HRESULT (WINAPI
*pVarCyMulI4
)(const CY
,LONG
,CY
*);
459 static HRESULT (WINAPI
*pVarCySub
)(const CY
,const CY
,CY
*);
460 static HRESULT (WINAPI
*pVarCyAbs
)(const CY
,CY
*);
461 static HRESULT (WINAPI
*pVarCyFix
)(const CY
,CY
*);
462 static HRESULT (WINAPI
*pVarCyInt
)(const CY
,CY
*);
463 static HRESULT (WINAPI
*pVarCyNeg
)(const CY
,CY
*);
464 static HRESULT (WINAPI
*pVarCyRound
)(const CY
,int,CY
*);
465 static HRESULT (WINAPI
*pVarCyCmp
)(const CY
,const CY
);
466 static HRESULT (WINAPI
*pVarCyCmpR8
)(const CY
,double);
467 static HRESULT (WINAPI
*pVarCyMulI8
)(const CY
,LONG64
,CY
*);
469 static HRESULT (WINAPI
*pVarDecFromUI1
)(BYTE
,DECIMAL
*);
470 static HRESULT (WINAPI
*pVarDecFromI2
)(SHORT
,DECIMAL
*);
471 static HRESULT (WINAPI
*pVarDecFromI4
)(LONG
,DECIMAL
*);
472 static HRESULT (WINAPI
*pVarDecFromI8
)(LONG64
,DECIMAL
*);
473 static HRESULT (WINAPI
*pVarDecFromR4
)(FLOAT
,DECIMAL
*);
474 static HRESULT (WINAPI
*pVarDecFromR8
)(DOUBLE
,DECIMAL
*);
475 static HRESULT (WINAPI
*pVarDecFromDate
)(DATE
,DECIMAL
*);
476 static HRESULT (WINAPI
*pVarDecFromStr
)(OLECHAR
*,LCID
,ULONG
,DECIMAL
*);
477 static HRESULT (WINAPI
*pVarDecFromBool
)(VARIANT_BOOL
,DECIMAL
*);
478 static HRESULT (WINAPI
*pVarDecFromI1
)(signed char,DECIMAL
*);
479 static HRESULT (WINAPI
*pVarDecFromUI2
)(USHORT
,DECIMAL
*);
480 static HRESULT (WINAPI
*pVarDecFromUI4
)(ULONG
,DECIMAL
*);
481 static HRESULT (WINAPI
*pVarDecFromUI8
)(ULONG64
,DECIMAL
*);
482 static HRESULT (WINAPI
*pVarDecFromCy
)(CY
,DECIMAL
*);
483 static HRESULT (WINAPI
*pVarDecAbs
)(const DECIMAL
*,DECIMAL
*);
484 static HRESULT (WINAPI
*pVarDecAdd
)(const DECIMAL
*,const DECIMAL
*,DECIMAL
*);
485 static HRESULT (WINAPI
*pVarDecSub
)(const DECIMAL
*,const DECIMAL
*,DECIMAL
*);
486 static HRESULT (WINAPI
*pVarDecMul
)(const DECIMAL
*,const DECIMAL
*,DECIMAL
*);
487 static HRESULT (WINAPI
*pVarDecDiv
)(const DECIMAL
*,const DECIMAL
*,DECIMAL
*);
488 static HRESULT (WINAPI
*pVarDecCmp
)(const DECIMAL
*,const DECIMAL
*);
489 static HRESULT (WINAPI
*pVarDecCmpR8
)(const DECIMAL
*,double);
490 static HRESULT (WINAPI
*pVarDecNeg
)(const DECIMAL
*,DECIMAL
*);
491 static HRESULT (WINAPI
*pVarDecRound
)(const DECIMAL
*,int,DECIMAL
*);
493 static HRESULT (WINAPI
*pVarBoolFromUI1
)(BYTE
,VARIANT_BOOL
*);
494 static HRESULT (WINAPI
*pVarBoolFromI2
)(SHORT
,VARIANT_BOOL
*);
495 static HRESULT (WINAPI
*pVarBoolFromI4
)(LONG
,VARIANT_BOOL
*);
496 static HRESULT (WINAPI
*pVarBoolFromR4
)(FLOAT
,VARIANT_BOOL
*);
497 static HRESULT (WINAPI
*pVarBoolFromR8
)(DOUBLE
,VARIANT_BOOL
*);
498 static HRESULT (WINAPI
*pVarBoolFromDate
)(DATE
,VARIANT_BOOL
*);
499 static HRESULT (WINAPI
*pVarBoolFromCy
)(CY
,VARIANT_BOOL
*);
500 static HRESULT (WINAPI
*pVarBoolFromStr
)(OLECHAR
*,LCID
,ULONG
,VARIANT_BOOL
*);
501 static HRESULT (WINAPI
*pVarBoolFromI1
)(signed char,VARIANT_BOOL
*);
502 static HRESULT (WINAPI
*pVarBoolFromUI2
)(USHORT
,VARIANT_BOOL
*);
503 static HRESULT (WINAPI
*pVarBoolFromUI4
)(ULONG
,VARIANT_BOOL
*);
504 static HRESULT (WINAPI
*pVarBoolFromDec
)(DECIMAL
*,VARIANT_BOOL
*);
505 static HRESULT (WINAPI
*pVarBoolFromI8
)(LONG64
,VARIANT_BOOL
*);
506 static HRESULT (WINAPI
*pVarBoolFromUI8
)(ULONG64
,VARIANT_BOOL
*);
508 static HRESULT (WINAPI
*pVarBstrFromR4
)(FLOAT
,LCID
,ULONG
,BSTR
*);
509 static HRESULT (WINAPI
*pVarBstrFromDate
)(DATE
,LCID
,ULONG
,BSTR
*);
510 static HRESULT (WINAPI
*pVarBstrFromCy
)(CY
,LCID
,ULONG
,BSTR
*);
511 static HRESULT (WINAPI
*pVarBstrFromDec
)(DECIMAL
*,LCID
,ULONG
,BSTR
*);
512 static HRESULT (WINAPI
*pVarBstrCmp
)(BSTR
,BSTR
,LCID
,ULONG
);
513 static HRESULT (WINAPI
*pVarBstrCat
)(BSTR
,BSTR
,BSTR
*);
515 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
516 static void (WINAPI
*pClearCustData
)(LPCUSTDATA
);
518 /* Internal representation of a BSTR */
519 typedef struct tagINTERNAL_BSTR
523 } INTERNAL_BSTR
, *LPINTERNAL_BSTR
;
527 IDispatch IDispatch_iface
;
533 static inline DummyDispatch
*impl_from_IDispatch(IDispatch
*iface
)
535 return CONTAINING_RECORD(iface
, DummyDispatch
, IDispatch_iface
);
538 static ULONG WINAPI
DummyDispatch_AddRef(IDispatch
*iface
)
540 DummyDispatch
*This
= impl_from_IDispatch(iface
);
541 return InterlockedIncrement(&This
->ref
);
544 static ULONG WINAPI
DummyDispatch_Release(IDispatch
*iface
)
546 DummyDispatch
*This
= impl_from_IDispatch(iface
);
547 return InterlockedDecrement(&This
->ref
);
550 static HRESULT WINAPI
DummyDispatch_QueryInterface(IDispatch
*iface
,
556 if (IsEqualIID(riid
, &IID_IDispatch
) ||
557 IsEqualIID(riid
, &IID_IUnknown
))
560 IDispatch_AddRef(iface
);
563 return *ppvObject
? S_OK
: E_NOINTERFACE
;
566 static HRESULT WINAPI
DummyDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
568 ok(0, "Unexpected call\n");
572 static HRESULT WINAPI
DummyDispatch_GetTypeInfo(IDispatch
*iface
, UINT tinfo
, LCID lcid
, ITypeInfo
**ti
)
574 ok(0, "Unexpected call\n");
578 static HRESULT WINAPI
DummyDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*names
,
579 UINT cnames
, LCID lcid
, DISPID
*dispid
)
581 ok(0, "Unexpected call\n");
585 static HRESULT WINAPI
DummyDispatch_Invoke(IDispatch
*iface
,
586 DISPID dispid
, REFIID riid
,
587 LCID lcid
, WORD wFlags
,
593 DummyDispatch
*This
= impl_from_IDispatch(iface
);
595 CHECK_EXPECT(dispatch_invoke
);
597 ok(dispid
== DISPID_VALUE
, "got dispid %d\n", dispid
);
598 ok(IsEqualIID(riid
, &IID_NULL
), "go riid %s\n", wine_dbgstr_guid(riid
));
599 ok(wFlags
== DISPATCH_PROPERTYGET
, "Flags wrong\n");
601 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
602 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
603 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
604 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
606 ok(res
!= NULL
, "got %p\n", res
);
607 ok(V_VT(res
) == VT_EMPTY
, "got %d\n", V_VT(res
));
608 ok(ei
== NULL
, "got %p\n", ei
);
609 ok(arg_err
== NULL
, "got %p\n", arg_err
);
611 if (This
->bFailInvoke
)
612 return E_OUTOFMEMORY
;
614 V_VT(res
) = This
->vt
;
615 if (This
->vt
== VT_UI1
)
618 memset(res
, 0, sizeof(*res
));
623 static const IDispatchVtbl DummyDispatch_VTable
=
625 DummyDispatch_QueryInterface
,
626 DummyDispatch_AddRef
,
627 DummyDispatch_Release
,
628 DummyDispatch_GetTypeInfoCount
,
629 DummyDispatch_GetTypeInfo
,
630 DummyDispatch_GetIDsOfNames
,
634 static void init_test_dispatch(LONG ref
, VARTYPE vt
, DummyDispatch
*dispatch
)
636 dispatch
->IDispatch_iface
.lpVtbl
= &DummyDispatch_VTable
;
639 dispatch
->bFailInvoke
= FALSE
;
647 #define CONV_TYPE signed char
649 #define EXPECTRES(res, x) _EXPECTRES(res, x, "%d")
651 static void test_VarI1FromI2(void)
656 CHECKPTR(VarI1FromI2
);
657 OVERFLOWRANGE(VarI1FromI2
, -32768, -128);
658 CONVERTRANGE(VarI1FromI2
, -128, 128);
659 OVERFLOWRANGE(VarI1FromI2
, 129, 32768);
662 static void test_VarI1FromI4(void)
667 CHECKPTR(VarI1FromI4
);
668 CONVERT(VarI1FromI4
, -129); EXPECT_OVERFLOW
;
669 CONVERTRANGE(VarI1FromI4
, -128, 128);
670 CONVERT(VarI1FromI4
, 128); EXPECT_OVERFLOW
;
673 static void test_VarI1FromI8(void)
678 CHECKPTR(VarI1FromI8
);
679 CONVERT(VarI1FromI8
, -129); EXPECT_OVERFLOW
;
680 CONVERTRANGE(VarI1FromI8
, -127, 128);
681 CONVERT(VarI1FromI8
, 128); EXPECT_OVERFLOW
;
684 static void test_VarI1FromUI1(void)
689 CHECKPTR(VarI1FromUI1
);
690 CONVERTRANGE(VarI1FromUI1
, 0, 127);
691 OVERFLOWRANGE(VarI1FromUI1
, 128, 255);
694 static void test_VarI1FromUI2(void)
699 CHECKPTR(VarI1FromUI2
);
700 CONVERTRANGE(VarI1FromUI2
, 0, 127);
701 OVERFLOWRANGE(VarI1FromUI2
, 128, 32768);
704 static void test_VarI1FromUI4(void)
709 CHECKPTR(VarI1FromUI4
);
710 CONVERTRANGE(VarI1FromUI4
, 0, 127);
711 CONVERT(VarI1FromUI4
, 128); EXPECT_OVERFLOW
;
714 static void test_VarI1FromUI8(void)
719 CHECKPTR(VarI1FromUI8
);
720 CONVERTRANGE(VarI1FromUI8
, 0, 127);
721 CONVERT(VarI1FromUI8
, 128); EXPECT_OVERFLOW
;
724 static void test_VarI1FromBool(void)
726 CONVVARS(VARIANT_BOOL
);
729 CHECKPTR(VarI1FromBool
);
730 /* Note that conversions from bool wrap around! */
731 CONVERT(VarI1FromBool
, -129); EXPECT(127);
732 CONVERTRANGE(VarI1FromBool
, -128, 128);
733 CONVERT(VarI1FromBool
, 128); EXPECT(-128);
736 static void test_VarI1FromR4(void)
740 CHECKPTR(VarI1FromR4
);
741 CONVERT(VarI1FromR4
, -129.0f
); EXPECT_OVERFLOW
;
742 CONVERT(VarI1FromR4
, -128.51f
); EXPECT_OVERFLOW
;
743 CONVERT(VarI1FromR4
, -128.5f
); EXPECT(-128);
744 CONVERT(VarI1FromR4
, -128.0f
); EXPECT(-128);
745 CONVERT(VarI1FromR4
, -1.0f
); EXPECT(-1);
746 CONVERT(VarI1FromR4
, 0.0f
); EXPECT(0);
747 CONVERT(VarI1FromR4
, 1.0f
); EXPECT(1);
748 CONVERT(VarI1FromR4
, 127.0f
); EXPECT(127);
749 CONVERT(VarI1FromR4
, 127.49f
); EXPECT(127);
750 CONVERT(VarI1FromR4
, 127.5f
); EXPECT_OVERFLOW
;
751 CONVERT(VarI1FromR4
, 128.0f
); EXPECT_OVERFLOW
;
753 CONVERT(VarI1FromR4
, -1.5f
); EXPECT(-2);
754 CONVERT(VarI1FromR4
, -0.6f
); EXPECT(-1);
755 CONVERT(VarI1FromR4
, -0.5f
); EXPECT(0);
756 CONVERT(VarI1FromR4
, -0.4f
); EXPECT(0);
757 CONVERT(VarI1FromR4
, 0.4f
); EXPECT(0);
758 CONVERT(VarI1FromR4
, 0.5f
); EXPECT(0);
759 CONVERT(VarI1FromR4
, 0.6f
); EXPECT(1);
760 CONVERT(VarI1FromR4
, 1.5f
); EXPECT(2);
763 static void test_VarI1FromR8(void)
767 CHECKPTR(VarI1FromR8
);
768 CONVERT(VarI1FromR8
, -129.0); EXPECT_OVERFLOW
;
769 CONVERT(VarI1FromR8
, -128.51); EXPECT_OVERFLOW
;
770 CONVERT(VarI1FromR8
, -128.5); EXPECT(-128);
771 CONVERT(VarI1FromR8
, -128.0); EXPECT(-128);
772 CONVERT(VarI1FromR8
, -1.0); EXPECT(-1);
773 CONVERT(VarI1FromR8
, 0.0); EXPECT(0);
774 CONVERT(VarI1FromR8
, 1.0); EXPECT(1);
775 CONVERT(VarI1FromR8
, 127.0); EXPECT(127);
776 CONVERT(VarI1FromR8
, 127.49); EXPECT(127);
777 CONVERT(VarI1FromR8
, 127.5); EXPECT_OVERFLOW
;
778 CONVERT(VarI1FromR8
, 128.0); EXPECT_OVERFLOW
;
780 CONVERT(VarI1FromR8
, -1.5); EXPECT(-2);
781 CONVERT(VarI1FromR8
, -0.6); EXPECT(-1);
782 CONVERT(VarI1FromR8
, -0.5); EXPECT(0);
783 CONVERT(VarI1FromR8
, -0.4); EXPECT(0);
784 CONVERT(VarI1FromR8
, 0.4); EXPECT(0);
785 CONVERT(VarI1FromR8
, 0.5); EXPECT(0);
786 CONVERT(VarI1FromR8
, 0.6); EXPECT(1);
787 CONVERT(VarI1FromR8
, 1.5); EXPECT(2);
790 static void test_VarI1FromDate(void)
794 CHECKPTR(VarI1FromDate
);
795 CONVERT(VarI1FromDate
, -129.0); EXPECT_OVERFLOW
;
796 CONVERT(VarI1FromDate
, -128.0); EXPECT(-128);
797 CONVERT(VarI1FromDate
, -1.0); EXPECT(-1);
798 CONVERT(VarI1FromDate
, 0.0); EXPECT(0);
799 CONVERT(VarI1FromDate
, 1.0); EXPECT(1);
800 CONVERT(VarI1FromDate
, 127.0); EXPECT(127);
801 CONVERT(VarI1FromDate
, 128.0); EXPECT_OVERFLOW
;
803 CONVERT(VarI1FromDate
, -1.5); EXPECT(-2);
804 CONVERT(VarI1FromDate
, -0.6); EXPECT(-1);
805 CONVERT(VarI1FromDate
, -0.5); EXPECT(0);
806 CONVERT(VarI1FromDate
, -0.4); EXPECT(0);
807 CONVERT(VarI1FromDate
, 0.4); EXPECT(0);
808 CONVERT(VarI1FromDate
, 0.5); EXPECT(0);
809 CONVERT(VarI1FromDate
, 0.6); EXPECT(1);
810 CONVERT(VarI1FromDate
, 1.5); EXPECT(2);
813 static void test_VarI1FromCy(void)
817 CHECKPTR(VarI1FromCy
);
818 CONVERT_CY(VarI1FromCy
,-129); EXPECT_OVERFLOW
;
819 CONVERT_CY(VarI1FromCy
,-128); EXPECT(128);
820 CONVERT_CY(VarI1FromCy
,-1); EXPECT(-1);
821 CONVERT_CY(VarI1FromCy
,0); EXPECT(0);
822 CONVERT_CY(VarI1FromCy
,1); EXPECT(1);
823 CONVERT_CY(VarI1FromCy
,127); EXPECT(127);
824 CONVERT_CY(VarI1FromCy
,128); EXPECT_OVERFLOW
;
826 CONVERT_CY(VarI1FromCy
,-1.5); EXPECT(-2);
827 CONVERT_CY(VarI1FromCy
,-0.6); EXPECT(-1);
828 CONVERT_CY(VarI1FromCy
,-0.5); EXPECT(0);
829 CONVERT_CY(VarI1FromCy
,-0.4); EXPECT(0);
830 CONVERT_CY(VarI1FromCy
,0.4); EXPECT(0);
831 CONVERT_CY(VarI1FromCy
,0.5); EXPECT(0);
832 CONVERT_CY(VarI1FromCy
,0.6); EXPECT(1);
833 CONVERT_CY(VarI1FromCy
,1.5); EXPECT(2);
836 static void test_VarI1FromDec(void)
840 CHECKPTR(VarI1FromDec
);
842 CONVERT_BADDEC(VarI1FromDec
);
844 CONVERT_DEC(VarI1FromDec
,0,0x80,0,129); EXPECT_OVERFLOW
;
845 CONVERT_DEC(VarI1FromDec
,0,0x80,0,128); EXPECT(-128);
846 CONVERT_DEC(VarI1FromDec
,0,0x80,0,1); EXPECT(-1);
847 CONVERT_DEC(VarI1FromDec
,0,0,0,0); EXPECT(0);
848 CONVERT_DEC(VarI1FromDec
,0,0,0,1); EXPECT(1);
849 CONVERT_DEC(VarI1FromDec
,0,0,0,127); EXPECT(127);
850 CONVERT_DEC(VarI1FromDec
,0,0,0,128); EXPECT_OVERFLOW
;
852 CONVERT_DEC(VarI1FromDec
,2,0x80,0,12800); EXPECT(-128);
853 CONVERT_DEC(VarI1FromDec
,2,0,0,12700); EXPECT(127);
856 static void test_VarI1FromStr(void)
861 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
863 CHECKPTR(VarI1FromStr
);
865 CONVERT_STR(VarI1FromStr
,NULL
, 0); EXPECT_MISMATCH
;
866 CONVERT_STR(VarI1FromStr
,"0", 0); EXPECT(0);
867 CONVERT_STR(VarI1FromStr
,"-129", 0); EXPECT_OVERFLOW
;
868 CONVERT_STR(VarI1FromStr
,"-128", 0); EXPECT(-128);
869 CONVERT_STR(VarI1FromStr
,"127", 0); EXPECT(127);
870 CONVERT_STR(VarI1FromStr
,"128", 0); EXPECT_OVERFLOW
;
872 CONVERT_STR(VarI1FromStr
,"-1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(-2);
873 CONVERT_STR(VarI1FromStr
,"-0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(-1);
874 CONVERT_STR(VarI1FromStr
,"-0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
875 CONVERT_STR(VarI1FromStr
,"-0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
876 CONVERT_STR(VarI1FromStr
,"0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
877 CONVERT_STR(VarI1FromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
878 CONVERT_STR(VarI1FromStr
,"0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(1);
879 CONVERT_STR(VarI1FromStr
,"1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(2);
882 static void test_VarI1Copy(void)
884 COPYTEST(1, VT_I1
, V_I1(&vSrc
), V_I1(&vDst
), V_I1REF(&vSrc
), V_I1REF(&vDst
), "%d");
887 static void test_VarI1ChangeTypeEx(void)
891 VARIANTARG vSrc
, vDst
;
895 INITIAL_TYPETEST(VT_I1
, V_I1
, "%d");
897 NEGATIVE_TYPETEST(VT_I1
, V_I1
, "%d", VT_UI1
, V_UI1
);
901 #define CONV_TYPE BYTE
903 static void test_VarUI1FromI1(void)
905 CONVVARS(signed char);
908 CHECKPTR(VarUI1FromI1
);
909 OVERFLOWRANGE(VarUI1FromI1
, -128, 0);
910 CONVERTRANGE(VarUI1FromI1
, 0, 128);
913 static void test_VarUI1FromI2(void)
918 CHECKPTR(VarUI1FromI2
);
919 OVERFLOWRANGE(VarUI1FromI2
, -32768, 0);
920 CONVERTRANGE(VarUI1FromI2
, 0, 256);
921 OVERFLOWRANGE(VarUI1FromI2
, 256, 32768);
924 static void test_VarUI1FromI4(void)
929 CHECKPTR(VarUI1FromI4
);
930 CONVERT(VarUI1FromI4
, -1); EXPECT_OVERFLOW
;
931 CONVERTRANGE(VarUI1FromI4
, 0, 256);
932 CONVERT(VarUI1FromI4
, 256); EXPECT_OVERFLOW
;
935 static void test_VarUI1FromI8(void)
940 CHECKPTR(VarUI1FromI8
);
941 CONVERT(VarUI1FromI8
, -1); EXPECT_OVERFLOW
;
942 CONVERTRANGE(VarUI1FromI8
, 0, 256);
943 CONVERT(VarUI1FromI8
, 256); EXPECT_OVERFLOW
;
946 static void test_VarUI1FromUI2(void)
951 CHECKPTR(VarUI1FromUI2
);
952 CONVERTRANGE(VarUI1FromUI2
, 0, 256);
953 OVERFLOWRANGE(VarUI1FromUI2
, 256, 65536);
956 static void test_VarUI1FromUI4(void)
961 CHECKPTR(VarUI1FromUI4
);
962 CONVERTRANGE(VarUI1FromUI4
, 0, 256);
963 CONVERT(VarUI1FromUI4
, 256); EXPECT_OVERFLOW
;
966 static void test_VarUI1FromUI8(void)
971 CHECKPTR(VarUI1FromUI8
);
972 CONVERTRANGE(VarUI1FromUI8
, 0, 256);
973 CONVERT(VarUI1FromUI8
, 256); EXPECT_OVERFLOW
;
976 static void test_VarUI1FromBool(void)
978 CONVVARS(VARIANT_BOOL
);
981 CHECKPTR(VarUI1FromBool
);
982 /* Note that conversions from bool overflow! */
983 CONVERT(VarUI1FromBool
, -1); EXPECT(255);
984 CONVERTRANGE(VarUI1FromBool
, 0, 256);
985 CONVERT(VarUI1FromBool
, 256); EXPECT(0);
988 static void test_VarUI1FromR4(void)
992 CHECKPTR(VarUI1FromR4
);
993 CONVERT(VarUI1FromR4
, -1.0f
); EXPECT_OVERFLOW
;
994 CONVERT(VarUI1FromR4
, -0.51f
); EXPECT_OVERFLOW
;
995 CONVERT(VarUI1FromR4
, -0.5f
); EXPECT(0);
996 CONVERT(VarUI1FromR4
, 0.0f
); EXPECT(0);
997 CONVERT(VarUI1FromR4
, 1.0f
); EXPECT(1);
998 CONVERT(VarUI1FromR4
, 255.0f
); EXPECT(255);
999 CONVERT(VarUI1FromR4
, 255.49f
); EXPECT(255);
1000 CONVERT(VarUI1FromR4
, 255.5f
); EXPECT_OVERFLOW
;
1001 CONVERT(VarUI1FromR4
, 256.0f
); EXPECT_OVERFLOW
;
1004 CONVERT(VarUI1FromR4
, -1.5f
); EXPECT_OVERFLOW
;
1005 CONVERT(VarUI1FromR4
, -0.6f
); EXPECT_OVERFLOW
;
1006 CONVERT(VarUI1FromR4
, -0.5f
); EXPECT(0);
1007 CONVERT(VarUI1FromR4
, -0.4f
); EXPECT(0);
1008 CONVERT(VarUI1FromR4
, 0.4f
); EXPECT(0);
1009 CONVERT(VarUI1FromR4
, 0.5f
); EXPECT(0);
1010 CONVERT(VarUI1FromR4
, 0.6f
); EXPECT(1);
1011 CONVERT(VarUI1FromR4
, 1.5f
); EXPECT(2);
1014 static void test_VarUI1FromR8(void)
1018 CHECKPTR(VarUI1FromR8
);
1019 CONVERT(VarUI1FromR8
, -1.0); EXPECT_OVERFLOW
;
1020 CONVERT(VarUI1FromR8
, -0.51); EXPECT_OVERFLOW
;
1021 CONVERT(VarUI1FromR8
, -0.5); EXPECT(0);
1022 CONVERT(VarUI1FromR8
, 0.0); EXPECT(0);
1023 CONVERT(VarUI1FromR8
, 1.0); EXPECT(1);
1024 CONVERT(VarUI1FromR8
, 255.0); EXPECT(255);
1025 CONVERT(VarUI1FromR8
, 255.49); EXPECT(255);
1026 CONVERT(VarUI1FromR8
, 255.5); EXPECT_OVERFLOW
;
1027 CONVERT(VarUI1FromR8
, 256.0); EXPECT_OVERFLOW
;
1030 CONVERT(VarUI1FromR8
, -1.5); EXPECT_OVERFLOW
;
1031 CONVERT(VarUI1FromR8
, -0.6); EXPECT_OVERFLOW
;
1032 CONVERT(VarUI1FromR8
, -0.5); EXPECT(0);
1033 CONVERT(VarUI1FromR8
, -0.4); EXPECT(0);
1034 CONVERT(VarUI1FromR8
, 0.4); EXPECT(0);
1035 CONVERT(VarUI1FromR8
, 0.5); EXPECT(0);
1036 CONVERT(VarUI1FromR8
, 0.6); EXPECT(1);
1037 CONVERT(VarUI1FromR8
, 1.5); EXPECT(2);
1040 static void test_VarUI1FromDate(void)
1044 CHECKPTR(VarUI1FromDate
);
1045 CONVERT(VarUI1FromDate
, -1.0); EXPECT_OVERFLOW
;
1046 CONVERT(VarUI1FromDate
, 0.0); EXPECT(0);
1047 CONVERT(VarUI1FromDate
, 1.0); EXPECT(1);
1048 CONVERT(VarUI1FromDate
, 255.0); EXPECT(255);
1049 CONVERT(VarUI1FromDate
, 256.0); EXPECT_OVERFLOW
;
1052 CONVERT(VarUI1FromDate
, -1.5); EXPECT_OVERFLOW
;
1053 CONVERT(VarUI1FromDate
, -0.6); EXPECT_OVERFLOW
;
1054 CONVERT(VarUI1FromDate
, -0.5); EXPECT(0);
1055 CONVERT(VarUI1FromDate
, -0.4); EXPECT(0);
1056 CONVERT(VarUI1FromDate
, 0.4); EXPECT(0);
1057 CONVERT(VarUI1FromDate
, 0.5); EXPECT(0);
1058 CONVERT(VarUI1FromDate
, 0.6); EXPECT(1);
1059 CONVERT(VarUI1FromDate
, 1.5); EXPECT(2);
1062 static void test_VarUI1FromCy(void)
1066 CHECKPTR(VarUI1FromCy
);
1067 CONVERT_CY(VarUI1FromCy
,-1); EXPECT_OVERFLOW
;
1068 CONVERT_CY(VarUI1FromCy
,0); EXPECT(0);
1069 CONVERT_CY(VarUI1FromCy
,1); EXPECT(1);
1070 CONVERT_CY(VarUI1FromCy
,255); EXPECT(255);
1071 CONVERT_CY(VarUI1FromCy
,256); EXPECT_OVERFLOW
;
1074 CONVERT_CY(VarUI1FromCy
,-1.5); EXPECT_OVERFLOW
;
1075 CONVERT_CY(VarUI1FromCy
,-0.6); EXPECT_OVERFLOW
;
1076 CONVERT_CY(VarUI1FromCy
,-0.5); EXPECT(0);
1077 CONVERT_CY(VarUI1FromCy
,-0.4); EXPECT(0);
1078 CONVERT_CY(VarUI1FromCy
,0.4); EXPECT(0);
1079 CONVERT_CY(VarUI1FromCy
,0.5); EXPECT(0);
1080 CONVERT_CY(VarUI1FromCy
,0.6); EXPECT(1);
1081 CONVERT_CY(VarUI1FromCy
,1.5); EXPECT(2);
1084 static void test_VarUI1FromDec(void)
1088 CHECKPTR(VarUI1FromDec
);
1090 CONVERT_BADDEC(VarUI1FromDec
);
1092 CONVERT_DEC(VarUI1FromDec
,0,0x80,0,1); EXPECT_OVERFLOW
;
1093 CONVERT_DEC(VarUI1FromDec
,0,0,0,0); EXPECT(0);
1094 CONVERT_DEC(VarUI1FromDec
,0,0,0,1); EXPECT(1);
1095 CONVERT_DEC(VarUI1FromDec
,0,0,0,255); EXPECT(255);
1096 CONVERT_DEC(VarUI1FromDec
,0,0,0,256); EXPECT_OVERFLOW
;
1098 CONVERT_DEC(VarUI1FromDec
,2,0x80,0,100); EXPECT_OVERFLOW
;
1099 CONVERT_DEC(VarUI1FromDec
,2,0,0,25500); EXPECT(255);
1102 static void test_VarUI1FromStr(void)
1107 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1109 CHECKPTR(VarUI1FromStr
);
1111 CONVERT_STR(VarUI1FromStr
,NULL
, 0); EXPECT_MISMATCH
;
1112 CONVERT_STR(VarUI1FromStr
,"0", 0); EXPECT(0);
1113 CONVERT_STR(VarUI1FromStr
,"-1", 0); EXPECT_OVERFLOW
;
1114 CONVERT_STR(VarUI1FromStr
,"255", 0); EXPECT(255);
1115 CONVERT_STR(VarUI1FromStr
,"256", 0); EXPECT_OVERFLOW
;
1118 CONVERT_STR(VarUI1FromStr
,"-1.5", LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
1119 CONVERT_STR(VarUI1FromStr
,"-0.6", LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
1120 CONVERT_STR(VarUI1FromStr
,"-0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1121 CONVERT_STR(VarUI1FromStr
,"-0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1122 CONVERT_STR(VarUI1FromStr
,"0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1123 CONVERT_STR(VarUI1FromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1124 CONVERT_STR(VarUI1FromStr
,"0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(1);
1125 CONVERT_STR(VarUI1FromStr
,"1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(2);
1128 static void test_VarUI1FromDisp(void)
1130 DummyDispatch dispatch
;
1132 VARIANTARG vSrc
, vDst
;
1134 CHECKPTR(VarUI1FromDisp
);
1137 * Conversions from IDispatch should get the default 'value' property
1138 * from the IDispatch pointer and return it. The following tests this.
1139 * However, I can't get these tests to return a valid value under native
1140 * oleaut32, regardless of the value returned in response to the Invoke()
1141 * call (early versions of oleaut32 call AddRef/Release, but not Invoke.
1142 * I'm obviously missing something, as these conversions work fine
1143 * when called through VBA on an object to get its default value property.
1145 * Should this test be corrected so that it works under native it should be
1146 * generalised and the remaining types checked as well.
1148 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1153 init_test_dispatch(1, VT_UI1
, &dispatch
);
1154 V_VT(&vSrc
) = VT_DISPATCH
;
1155 V_DISPATCH(&vSrc
) = &dispatch
.IDispatch_iface
;
1157 SET_EXPECT(dispatch_invoke
);
1159 hres
= pVarUI1FromDisp(&dispatch
.IDispatch_iface
, in
, &out
);
1160 ok(broken(hres
== DISP_E_BADVARTYPE
) || hres
== S_OK
, "got 0x%08x\n", hres
);
1161 ok(broken(out
== 10) || out
== 1, "got %d\n", out
);
1162 CHECK_CALLED(dispatch_invoke
);
1164 SET_EXPECT(dispatch_invoke
);
1165 V_VT(&vDst
) = VT_EMPTY
;
1167 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, in
, 0, VT_UI1
);
1168 ok(hres
== S_OK
, "got 0x%08x\n", hres
);
1169 ok(V_VT(&vDst
) == VT_UI1
, "got %d\n", V_VT(&vDst
));
1170 ok(V_UI1(&vDst
) == 1, "got %d\n", V_UI1(&vDst
));
1171 CHECK_CALLED(dispatch_invoke
);
1173 dispatch
.bFailInvoke
= TRUE
;
1175 SET_EXPECT(dispatch_invoke
);
1177 hres
= pVarUI1FromDisp(&dispatch
.IDispatch_iface
, in
, &out
);
1178 ok(hres
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hres
);
1179 ok(out
== 10, "got %d\n", out
);
1180 CHECK_CALLED(dispatch_invoke
);
1182 SET_EXPECT(dispatch_invoke
);
1183 V_VT(&vDst
) = VT_EMPTY
;
1184 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, in
, 0, VT_UI1
);
1185 ok(hres
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hres
);
1186 ok(V_VT(&vDst
) == VT_EMPTY
, "got %d\n", V_VT(&vDst
));
1187 CHECK_CALLED(dispatch_invoke
);
1190 static void test_VarUI1Copy(void)
1192 COPYTEST(1, VT_UI1
, V_UI1(&vSrc
), V_UI1(&vDst
), V_UI1REF(&vSrc
), V_UI1REF(&vDst
), "%d");
1195 static void test_VarUI1ChangeTypeEx(void)
1199 VARIANTARG vSrc
, vDst
;
1203 INITIAL_TYPETEST(VT_UI1
, V_UI1
, "%d");
1205 NEGATIVE_TYPETEST(VT_UI1
, V_UI1
, "%d", VT_I1
, V_I1
);
1213 #define CONV_TYPE SHORT
1215 static void test_VarI2FromI1(void)
1217 CONVVARS(signed char);
1220 CHECKPTR(VarI2FromI1
);
1221 CONVERTRANGE(VarI2FromI1
, -128, 128);
1224 static void test_VarI2FromI4(void)
1229 CHECKPTR(VarI2FromI4
);
1230 CONVERT(VarI2FromI4
, -32769); EXPECT_OVERFLOW
;
1231 CONVERTRANGE(VarI2FromI4
, -32768, 32768);
1232 CONVERT(VarI2FromI4
, 32768); EXPECT_OVERFLOW
;
1235 static void test_VarI2FromI8(void)
1239 CHECKPTR(VarI2FromI8
);
1240 CONVERT(VarI2FromI8
, -32769); EXPECT_OVERFLOW
;
1241 CONVERT(VarI2FromI8
, -32768); EXPECT(-32768);
1242 CONVERT(VarI2FromI8
, 32767); EXPECT(32767);
1243 CONVERT(VarI2FromI8
, 32768); EXPECT_OVERFLOW
;
1246 static void test_VarI2FromUI1(void)
1251 CHECKPTR(VarI2FromUI1
);
1252 CONVERTRANGE(VarI2FromUI1
, 0, 256);
1255 static void test_VarI2FromUI2(void)
1260 CHECKPTR(VarI2FromUI2
);
1261 CONVERTRANGE(VarI2FromUI2
, 0, 32768);
1262 CONVERT(VarI2FromUI2
, 32768); EXPECT_OVERFLOW
;
1265 static void test_VarI2FromUI4(void)
1270 CHECKPTR(VarI2FromUI4
);
1271 CONVERTRANGE(VarI2FromUI4
, 0, 32768);
1272 CONVERT(VarI2FromUI4
, 32768); EXPECT_OVERFLOW
;
1275 static void test_VarI2FromUI8(void)
1280 CHECKPTR(VarI2FromUI8
);
1281 CONVERTRANGE(VarI2FromUI8
, 0, 32768);
1282 CONVERT(VarI2FromUI8
, 32768); EXPECT_OVERFLOW
;
1285 static void test_VarI2FromBool(void)
1287 CONVVARS(VARIANT_BOOL
);
1290 CHECKPTR(VarI2FromBool
);
1291 CONVERTRANGE(VarI2FromBool
, -32768, 32768);
1294 static void test_VarI2FromR4(void)
1298 CHECKPTR(VarI2FromR4
);
1299 CONVERT(VarI2FromR4
, -32769.0f
); EXPECT_OVERFLOW
;
1300 CONVERT(VarI2FromR4
, -32768.51f
); EXPECT_OVERFLOW
;
1301 CONVERT(VarI2FromR4
, -32768.5f
); EXPECT(-32768);
1302 CONVERT(VarI2FromR4
, -32768.0f
); EXPECT(-32768);
1303 CONVERT(VarI2FromR4
, -1.0f
); EXPECT(-1);
1304 CONVERT(VarI2FromR4
, 0.0f
); EXPECT(0);
1305 CONVERT(VarI2FromR4
, 1.0f
); EXPECT(1);
1306 CONVERT(VarI2FromR4
, 32767.0f
); EXPECT(32767);
1307 CONVERT(VarI2FromR4
, 32767.49f
); EXPECT(32767);
1308 CONVERT(VarI2FromR4
, 32767.5f
); EXPECT_OVERFLOW
;
1309 CONVERT(VarI2FromR4
, 32768.0f
); EXPECT_OVERFLOW
;
1312 CONVERT(VarI2FromR4
, -1.5f
); EXPECT(-2);
1313 CONVERT(VarI2FromR4
, -0.6f
); EXPECT(-1);
1314 CONVERT(VarI2FromR4
, -0.5f
); EXPECT(0);
1315 CONVERT(VarI2FromR4
, -0.4f
); EXPECT(0);
1316 CONVERT(VarI2FromR4
, 0.4f
); EXPECT(0);
1317 CONVERT(VarI2FromR4
, 0.5f
); EXPECT(0);
1318 CONVERT(VarI2FromR4
, 0.6f
); EXPECT(1);
1319 CONVERT(VarI2FromR4
, 1.5f
); EXPECT(2);
1322 static void test_VarI2FromR8(void)
1326 CHECKPTR(VarI2FromR8
);
1327 CONVERT(VarI2FromR8
, -32769.0); EXPECT_OVERFLOW
;
1328 CONVERT(VarI2FromR8
, -32768.51); EXPECT_OVERFLOW
;
1329 CONVERT(VarI2FromR8
, -32768.5); EXPECT(-32768);
1330 CONVERT(VarI2FromR8
, -32768.0); EXPECT(-32768);
1331 CONVERT(VarI2FromR8
, -1.0); EXPECT(-1);
1332 CONVERT(VarI2FromR8
, 0.0); EXPECT(0);
1333 CONVERT(VarI2FromR8
, 1.0); EXPECT(1);
1334 CONVERT(VarI2FromR8
, 32767.0); EXPECT(32767);
1335 CONVERT(VarI2FromR8
, 32767.49); EXPECT(32767);
1336 CONVERT(VarI2FromR8
, 32767.5); EXPECT_OVERFLOW
;
1337 CONVERT(VarI2FromR8
, 32768.0); EXPECT_OVERFLOW
;
1340 CONVERT(VarI2FromR8
, -1.5); EXPECT(-2);
1341 CONVERT(VarI2FromR8
, -0.6); EXPECT(-1);
1342 CONVERT(VarI2FromR8
, -0.5); EXPECT(0);
1343 CONVERT(VarI2FromR8
, -0.4); EXPECT(0);
1344 CONVERT(VarI2FromR8
, 0.4); EXPECT(0);
1345 CONVERT(VarI2FromR8
, 0.5); EXPECT(0);
1346 CONVERT(VarI2FromR8
, 0.6); EXPECT(1);
1347 CONVERT(VarI2FromR8
, 1.5); EXPECT(2);
1350 static void test_VarI2FromDate(void)
1354 CHECKPTR(VarI2FromDate
);
1355 CONVERT(VarI2FromDate
, -32769.0); EXPECT_OVERFLOW
;
1356 CONVERT(VarI2FromDate
, -32768.0); EXPECT(-32768);
1357 CONVERT(VarI2FromDate
, -1.0); EXPECT(-1);
1358 CONVERT(VarI2FromDate
, 0.0); EXPECT(0);
1359 CONVERT(VarI2FromDate
, 1.0); EXPECT(1);
1360 CONVERT(VarI2FromDate
, 32767.0); EXPECT(32767);
1361 CONVERT(VarI2FromDate
, 32768.0); EXPECT_OVERFLOW
;
1364 CONVERT(VarI2FromDate
, -1.5); EXPECT(-2);
1365 CONVERT(VarI2FromDate
, -0.6); EXPECT(-1);
1366 CONVERT(VarI2FromDate
, -0.5); EXPECT(0);
1367 CONVERT(VarI2FromDate
, -0.4); EXPECT(0);
1368 CONVERT(VarI2FromDate
, 0.4); EXPECT(0);
1369 CONVERT(VarI2FromDate
, 0.5); EXPECT(0);
1370 CONVERT(VarI2FromDate
, 0.6); EXPECT(1);
1371 CONVERT(VarI2FromDate
, 1.5); EXPECT(2);
1374 static void test_VarI2FromCy(void)
1378 CHECKPTR(VarI2FromCy
);
1379 CONVERT_CY(VarI2FromCy
,-32769); EXPECT_OVERFLOW
;
1380 CONVERT_CY(VarI2FromCy
,-32768); EXPECT(32768);
1381 CONVERT_CY(VarI2FromCy
,-1); EXPECT(-1);
1382 CONVERT_CY(VarI2FromCy
,0); EXPECT(0);
1383 CONVERT_CY(VarI2FromCy
,1); EXPECT(1);
1384 CONVERT_CY(VarI2FromCy
,32767); EXPECT(32767);
1385 CONVERT_CY(VarI2FromCy
,32768); EXPECT_OVERFLOW
;
1388 CONVERT_CY(VarI2FromCy
,-1.5); EXPECT(-2);
1389 CONVERT_CY(VarI2FromCy
,-0.6); EXPECT(-1);
1390 CONVERT_CY(VarI2FromCy
,-0.5); EXPECT(0);
1391 CONVERT_CY(VarI2FromCy
,-0.4); EXPECT(0);
1392 CONVERT_CY(VarI2FromCy
,0.4); EXPECT(0);
1393 CONVERT_CY(VarI2FromCy
,0.5); EXPECT(0);
1394 CONVERT_CY(VarI2FromCy
,0.6); EXPECT(1);
1395 CONVERT_CY(VarI2FromCy
,1.5); EXPECT(2);
1398 static void test_VarI2FromDec(void)
1402 CHECKPTR(VarI2FromDec
);
1404 CONVERT_BADDEC(VarI2FromDec
);
1406 CONVERT_DEC(VarI2FromDec
,0,0x80,0,32769); EXPECT_OVERFLOW
;
1407 CONVERT_DEC(VarI2FromDec
,0,0x80,0,32768); EXPECT(-32768);
1408 CONVERT_DEC(VarI2FromDec
,0,0x80,0,1); EXPECT(-1);
1409 CONVERT_DEC(VarI2FromDec
,0,0,0,0); EXPECT(0);
1410 CONVERT_DEC(VarI2FromDec
,0,0,0,1); EXPECT(1);
1411 CONVERT_DEC(VarI2FromDec
,0,0,0,32767); EXPECT(32767);
1412 CONVERT_DEC(VarI2FromDec
,0,0,0,32768); EXPECT_OVERFLOW
;
1414 CONVERT_DEC(VarI2FromDec
,2,0x80,0,3276800); EXPECT(-32768);
1415 CONVERT_DEC(VarI2FromDec
,2,0,0,3276700); EXPECT(32767);
1416 CONVERT_DEC(VarI2FromDec
,2,0,0,3276800); EXPECT_OVERFLOW
;
1419 static void test_VarI2FromStr(void)
1424 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1426 CHECKPTR(VarI2FromStr
);
1428 CONVERT_STR(VarI2FromStr
,NULL
, 0); EXPECT_MISMATCH
;
1429 CONVERT_STR(VarI2FromStr
,"0", 0); EXPECT(0);
1430 CONVERT_STR(VarI2FromStr
,"-32769", 0); EXPECT_OVERFLOW
;
1431 CONVERT_STR(VarI2FromStr
,"-32768", 0); EXPECT(-32768);
1432 CONVERT_STR(VarI2FromStr
,"32767", 0); EXPECT(32767);
1433 CONVERT_STR(VarI2FromStr
,"32768", 0); EXPECT_OVERFLOW
;
1436 CONVERT_STR(VarI2FromStr
,"-1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(-2);
1437 CONVERT_STR(VarI2FromStr
,"-0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(-1);
1438 CONVERT_STR(VarI2FromStr
,"-0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1439 CONVERT_STR(VarI2FromStr
,"-0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1440 CONVERT_STR(VarI2FromStr
,"0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1441 CONVERT_STR(VarI2FromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1442 CONVERT_STR(VarI2FromStr
,"0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(1);
1443 CONVERT_STR(VarI2FromStr
,"1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(2);
1446 static void test_VarI2Copy(void)
1448 COPYTEST(1, VT_I2
, V_I2(&vSrc
), V_I2(&vDst
), V_I2REF(&vSrc
), V_I2REF(&vDst
), "%d");
1451 static void test_VarI2ChangeTypeEx(void)
1455 VARIANTARG vSrc
, vDst
;
1459 INITIAL_TYPETEST(VT_I2
, V_I2
, "%d");
1461 NEGATIVE_TYPETEST(VT_I2
, V_I2
, "%d", VT_UI2
, V_UI2
);
1465 #define CONV_TYPE USHORT
1467 static void test_VarUI2FromI1(void)
1469 CONVVARS(signed char);
1472 CHECKPTR(VarUI2FromI1
);
1473 OVERFLOWRANGE(VarUI2FromI1
, -128, 0);
1474 CONVERTRANGE(VarUI2FromI1
, 0, 128);
1477 static void test_VarUI2FromI2(void)
1482 CHECKPTR(VarUI2FromI2
);
1483 OVERFLOWRANGE(VarUI2FromI2
, -32768, 0);
1484 CONVERTRANGE(VarUI2FromI2
, 0, 32768);
1487 static void test_VarUI2FromI4(void)
1492 CHECKPTR(VarUI2FromI4
);
1493 OVERFLOWRANGE(VarUI2FromI4
, -32768, 0);
1494 CONVERT(VarUI2FromI4
, 0); EXPECT(0);
1495 CONVERT(VarUI2FromI4
, 65535); EXPECT(65535);
1496 CONVERT(VarUI2FromI4
, 65536); EXPECT_OVERFLOW
;
1499 static void test_VarUI2FromI8(void)
1504 CHECKPTR(VarUI2FromI8
);
1505 OVERFLOWRANGE(VarUI2FromI8
, -32768, 0);
1506 CONVERT(VarUI2FromI8
, 0); EXPECT(0);
1507 CONVERT(VarUI2FromI8
, 65535); EXPECT(65535);
1508 CONVERT(VarUI2FromI8
, 65536); EXPECT_OVERFLOW
;
1511 static void test_VarUI2FromUI1(void)
1516 CHECKPTR(VarUI2FromUI1
);
1517 CONVERTRANGE(VarUI2FromUI1
, 0, 256);
1520 static void test_VarUI2FromUI4(void)
1524 CHECKPTR(VarUI2FromUI4
);
1525 CONVERT(VarUI2FromUI4
, 0); EXPECT(0);
1526 CONVERT(VarUI2FromUI4
, 65535); EXPECT(65535);
1527 CONVERT(VarUI2FromUI4
, 65536); EXPECT_OVERFLOW
;
1530 static void test_VarUI2FromUI8(void)
1534 CHECKPTR(VarUI2FromUI8
);
1535 CONVERT(VarUI2FromUI8
, 0); EXPECT(0);
1536 CONVERT(VarUI2FromUI8
, 65535); EXPECT(65535);
1537 CONVERT(VarUI2FromUI8
, 65536); EXPECT_OVERFLOW
;
1540 static void test_VarUI2FromBool(void)
1542 CONVVARS(VARIANT_BOOL
);
1545 CHECKPTR(VarUI2FromBool
);
1546 CONVERT(VarUI2FromBool
, -1); EXPECT(65535); /* Wraps! */
1547 CONVERTRANGE(VarUI2FromBool
, 0, 32768);
1550 static void test_VarUI2FromR4(void)
1554 CHECKPTR(VarUI2FromR4
);
1555 CONVERT(VarUI2FromR4
, -1.0f
); EXPECT_OVERFLOW
;
1556 CONVERT(VarUI2FromR4
, -0.51f
); EXPECT_OVERFLOW
;
1557 CONVERT(VarUI2FromR4
, -0.5f
); EXPECT(0);
1558 CONVERT(VarUI2FromR4
, 0.0f
); EXPECT(0);
1559 CONVERT(VarUI2FromR4
, 1.0f
); EXPECT(1);
1560 CONVERT(VarUI2FromR4
, 65535.0f
); EXPECT(65535);
1561 CONVERT(VarUI2FromR4
, 65535.49f
); EXPECT(65535);
1562 CONVERT(VarUI2FromR4
, 65535.5f
); EXPECT_OVERFLOW
;
1563 CONVERT(VarUI2FromR4
, 65536.0f
); EXPECT_OVERFLOW
;
1566 CONVERT(VarUI2FromR4
, -1.5f
); EXPECT_OVERFLOW
;
1567 CONVERT(VarUI2FromR4
, -0.6f
); EXPECT_OVERFLOW
;
1568 CONVERT(VarUI2FromR4
, -0.5f
); EXPECT(0);
1569 CONVERT(VarUI2FromR4
, -0.4f
); EXPECT(0);
1570 CONVERT(VarUI2FromR4
, 0.4f
); EXPECT(0);
1571 CONVERT(VarUI2FromR4
, 0.5f
); EXPECT(0);
1572 CONVERT(VarUI2FromR4
, 0.6f
); EXPECT(1);
1573 CONVERT(VarUI2FromR4
, 1.5f
); EXPECT(2);
1576 static void test_VarUI2FromR8(void)
1580 CHECKPTR(VarUI2FromR8
);
1581 CONVERT(VarUI2FromR8
, -1.0); EXPECT_OVERFLOW
;
1582 CONVERT(VarUI2FromR8
, -0.51); EXPECT_OVERFLOW
;
1583 CONVERT(VarUI2FromR8
, -0.5); EXPECT(0);
1584 CONVERT(VarUI2FromR8
, 0.0); EXPECT(0);
1585 CONVERT(VarUI2FromR8
, 1.0); EXPECT(1);
1586 CONVERT(VarUI2FromR8
, 65535.0); EXPECT(65535);
1587 CONVERT(VarUI2FromR8
, 65535.49); EXPECT(65535);
1588 CONVERT(VarUI2FromR8
, 65535.5); EXPECT_OVERFLOW
;
1589 CONVERT(VarUI2FromR8
, 65536.0); EXPECT_OVERFLOW
;
1592 CONVERT(VarUI2FromR8
, -1.5); EXPECT_OVERFLOW
;
1593 CONVERT(VarUI2FromR8
, -0.6); EXPECT_OVERFLOW
;
1594 CONVERT(VarUI2FromR8
, -0.5); EXPECT(0);
1595 CONVERT(VarUI2FromR8
, -0.4); EXPECT(0);
1596 CONVERT(VarUI2FromR8
, 0.4); EXPECT(0);
1597 CONVERT(VarUI2FromR8
, 0.5); EXPECT(0);
1598 CONVERT(VarUI2FromR8
, 0.6); EXPECT(1);
1599 CONVERT(VarUI2FromR8
, 1.5); EXPECT(2);
1602 static void test_VarUI2FromDate(void)
1606 CHECKPTR(VarUI2FromDate
);
1607 CONVERT(VarUI2FromDate
, -1.0); EXPECT_OVERFLOW
;
1608 CONVERT(VarUI2FromDate
, 0.0); EXPECT(0);
1609 CONVERT(VarUI2FromDate
, 1.0); EXPECT(1);
1610 CONVERT(VarUI2FromDate
, 65535.0); EXPECT(65535);
1611 CONVERT(VarUI2FromDate
, 65536.0); EXPECT_OVERFLOW
;
1614 CONVERT(VarUI2FromDate
, -1.5); EXPECT_OVERFLOW
;
1615 CONVERT(VarUI2FromDate
, -0.6); EXPECT_OVERFLOW
;
1616 CONVERT(VarUI2FromDate
, -0.5); EXPECT(0);
1617 CONVERT(VarUI2FromDate
, -0.4); EXPECT(0);
1618 CONVERT(VarUI2FromDate
, 0.4); EXPECT(0);
1619 CONVERT(VarUI2FromDate
, 0.5); EXPECT(0);
1620 CONVERT(VarUI2FromDate
, 0.6); EXPECT(1);
1621 CONVERT(VarUI2FromDate
, 1.5); EXPECT(2);
1624 static void test_VarUI2FromCy(void)
1628 CHECKPTR(VarUI2FromCy
);
1629 CONVERT_CY(VarUI2FromCy
,-1); EXPECT_OVERFLOW
;
1630 CONVERT_CY(VarUI2FromCy
,0); EXPECT(0);
1631 CONVERT_CY(VarUI2FromCy
,1); EXPECT(1);
1632 CONVERT_CY(VarUI2FromCy
,65535); EXPECT(65535);
1633 CONVERT_CY(VarUI2FromCy
,65536); EXPECT_OVERFLOW
;
1636 CONVERT_CY(VarUI2FromCy
,-1.5); EXPECT_OVERFLOW
;
1637 CONVERT_CY(VarUI2FromCy
,-0.6); EXPECT_OVERFLOW
;
1638 CONVERT_CY(VarUI2FromCy
,-0.5); EXPECT(0);
1639 CONVERT_CY(VarUI2FromCy
,-0.4); EXPECT(0);
1640 CONVERT_CY(VarUI2FromCy
,0.4); EXPECT(0);
1641 CONVERT_CY(VarUI2FromCy
,0.5); EXPECT(0);
1642 CONVERT_CY(VarUI2FromCy
,0.6); EXPECT(1);
1643 CONVERT_CY(VarUI2FromCy
,1.5); EXPECT(2);
1646 static void test_VarUI2FromDec(void)
1650 CHECKPTR(VarUI2FromDec
);
1652 CONVERT_BADDEC(VarUI2FromDec
);
1654 CONVERT_DEC(VarUI2FromDec
,0,0x80,0,1); EXPECT_OVERFLOW
;
1655 CONVERT_DEC(VarUI2FromDec
,0,0,0,0); EXPECT(0);
1656 CONVERT_DEC(VarUI2FromDec
,0,0,0,1); EXPECT(1);
1657 CONVERT_DEC(VarUI2FromDec
,0,0,0,65535); EXPECT(65535);
1658 CONVERT_DEC(VarUI2FromDec
,0,0,0,65536); EXPECT_OVERFLOW
;
1660 CONVERT_DEC(VarUI2FromDec
,2,0x80,0,100); EXPECT_OVERFLOW
;
1661 CONVERT_DEC(VarUI2FromDec
,2,0,0,6553500); EXPECT(65535);
1662 CONVERT_DEC(VarUI2FromDec
,2,0,0,6553600); EXPECT_OVERFLOW
;
1665 static void test_VarUI2FromStr(void)
1670 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1672 CHECKPTR(VarUI2FromStr
);
1674 CONVERT_STR(VarUI2FromStr
,NULL
, 0); EXPECT_MISMATCH
;
1675 CONVERT_STR(VarUI2FromStr
,"0", 0); EXPECT(0);
1676 CONVERT_STR(VarUI2FromStr
,"-1", 0); EXPECT_OVERFLOW
;
1677 CONVERT_STR(VarUI2FromStr
,"65535", 0); EXPECT(65535);
1678 CONVERT_STR(VarUI2FromStr
,"65536", 0); EXPECT_OVERFLOW
;
1681 CONVERT_STR(VarUI2FromStr
,"-1.5", LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
1682 CONVERT_STR(VarUI2FromStr
,"-0.6", LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
1683 CONVERT_STR(VarUI2FromStr
,"-0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1684 CONVERT_STR(VarUI2FromStr
,"-0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1685 CONVERT_STR(VarUI2FromStr
,"0.4", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1686 CONVERT_STR(VarUI2FromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1687 CONVERT_STR(VarUI2FromStr
,"0.6", LOCALE_NOUSEROVERRIDE
); EXPECT(1);
1688 CONVERT_STR(VarUI2FromStr
,"1.5", LOCALE_NOUSEROVERRIDE
); EXPECT(2);
1691 static void test_VarUI2Copy(void)
1693 COPYTEST(1, VT_UI2
, V_UI2(&vSrc
), V_UI2(&vDst
), V_UI2REF(&vSrc
), V_UI2REF(&vDst
), "%d");
1696 static void test_VarUI2ChangeTypeEx(void)
1700 VARIANTARG vSrc
, vDst
;
1704 INITIAL_TYPETEST(VT_UI2
, V_UI2
, "%d");
1706 NEGATIVE_TYPETEST(VT_UI2
, V_UI2
, "%d", VT_I2
, V_I2
);
1714 #define CONV_TYPE LONG
1716 static void test_VarI4FromI1(void)
1718 CONVVARS(signed char);
1721 CHECKPTR(VarI4FromI1
);
1722 CONVERTRANGE(VarI4FromI1
, -128, 128);
1725 static void test_VarI4FromI2(void)
1730 CHECKPTR(VarI4FromI2
);
1731 CONVERTRANGE(VarI4FromI2
, -32768, 32768);
1734 static void test_VarI4FromI8(void)
1738 CHECKPTR(VarI4FromI8
);
1739 CHECKPTR(VarI4FromDec
);
1741 CONVERT(VarI4FromI8
, -1); EXPECT(-1);
1742 CONVERT(VarI4FromI8
, 0); EXPECT(0);
1743 CONVERT(VarI4FromI8
, 1); EXPECT(1);
1745 CONVERT_I8(VarI4FromI8
, -1, 2147483647ul); EXPECT_OVERFLOW
;
1746 CONVERT_I8(VarI4FromI8
, -1, 2147483648ul); EXPECT(-2147483647 - 1);
1747 CONVERT_I8(VarI4FromI8
, 0, 2147483647ul); EXPECT(2147483647);
1748 CONVERT_I8(VarI4FromI8
, 0, 2147483648ul); EXPECT_OVERFLOW
;
1751 static void test_VarI4FromUI1(void)
1756 CHECKPTR(VarI4FromUI1
);
1757 CONVERTRANGE(VarI4FromUI1
, 0, 256);
1760 static void test_VarI4FromUI2(void)
1765 CHECKPTR(VarI4FromUI2
);
1766 CONVERTRANGE(VarI4FromUI2
, 0, 65536);
1769 static void test_VarI4FromUI4(void)
1773 CHECKPTR(VarI4FromUI4
);
1774 CONVERT(VarI4FromUI4
, 0); EXPECT(0);
1775 CONVERT(VarI4FromUI4
, 1); EXPECT(1);
1776 CONVERT(VarI4FromUI4
, 2147483647); EXPECT(2147483647);
1777 CONVERT(VarI4FromUI4
, 2147483648ul); EXPECT_OVERFLOW
;
1780 static void test_VarI4FromUI8(void)
1784 CHECKPTR(VarI4FromUI8
);
1785 CONVERT(VarI4FromUI8
, 0); EXPECT(0);
1786 CONVERT(VarI4FromUI8
, 1); EXPECT(1);
1787 CONVERT(VarI4FromUI8
, 2147483647); EXPECT(2147483647);
1788 CONVERT(VarI4FromUI8
, 2147483648ul); EXPECT_OVERFLOW
;
1791 static void test_VarI4FromBool(void)
1793 CONVVARS(VARIANT_BOOL
);
1796 CHECKPTR(VarI4FromBool
);
1797 CONVERTRANGE(VarI4FromBool
, -32768, 32768);
1800 static void test_VarI4FromR4(void)
1804 CHECKPTR(VarI4FromR4
);
1806 /* min/max values are not exactly representable in a float */
1807 CONVERT(VarI4FromR4
, -1.0f
); EXPECT(-1);
1808 CONVERT(VarI4FromR4
, 0.0f
); EXPECT(0);
1809 CONVERT(VarI4FromR4
, 1.0f
); EXPECT(1);
1811 CONVERT(VarI4FromR4
, -1.5f
); EXPECT(-2);
1812 CONVERT(VarI4FromR4
, -0.6f
); EXPECT(-1);
1813 CONVERT(VarI4FromR4
, -0.5f
); EXPECT(0);
1814 CONVERT(VarI4FromR4
, -0.4f
); EXPECT(0);
1815 CONVERT(VarI4FromR4
, 0.4f
); EXPECT(0);
1816 CONVERT(VarI4FromR4
, 0.5f
); EXPECT(0);
1817 CONVERT(VarI4FromR4
, 0.6f
); EXPECT(1);
1818 CONVERT(VarI4FromR4
, 1.5f
); EXPECT(2);
1821 static void test_VarI4FromR8(void)
1825 CHECKPTR(VarI4FromR8
);
1826 CONVERT(VarI4FromR8
, -2147483649.0); EXPECT_OVERFLOW
;
1827 CONVERT(VarI4FromR8
, -2147483648.51); EXPECT_OVERFLOW
;
1828 CONVERT(VarI4FromR8
, -2147483648.5); EXPECT(-2147483647 - 1);
1829 CONVERT(VarI4FromR8
, -2147483648.0); EXPECT(-2147483647 - 1);
1830 CONVERT(VarI4FromR8
, -1.0); EXPECT(-1);
1831 CONVERT(VarI4FromR8
, 0.0); EXPECT(0);
1832 CONVERT(VarI4FromR8
, 1.0); EXPECT(1);
1833 CONVERT(VarI4FromR8
, 2147483647.0); EXPECT(2147483647);
1834 CONVERT(VarI4FromR8
, 2147483647.49); EXPECT(2147483647);
1835 CONVERT(VarI4FromR8
, 2147483647.5); EXPECT_OVERFLOW
;
1836 CONVERT(VarI4FromR8
, 2147483648.0); EXPECT_OVERFLOW
;
1838 CONVERT(VarI4FromR8
, -1.5); EXPECT(-2);
1839 CONVERT(VarI4FromR8
, -0.6); EXPECT(-1);
1840 CONVERT(VarI4FromR8
, -0.5); EXPECT(0);
1841 CONVERT(VarI4FromR8
, -0.4); EXPECT(0);
1842 CONVERT(VarI4FromR8
, 0.4); EXPECT(0);
1843 CONVERT(VarI4FromR8
, 0.5); EXPECT(0);
1844 CONVERT(VarI4FromR8
, 0.6); EXPECT(1);
1845 CONVERT(VarI4FromR8
, 1.5); EXPECT(2);
1848 static void test_VarI4FromDate(void)
1852 CHECKPTR(VarI4FromDate
);
1853 CONVERT(VarI4FromDate
, -2147483649.0); EXPECT_OVERFLOW
;
1854 CONVERT(VarI4FromDate
, -2147483648.0); EXPECT(-2147483647 - 1);
1855 CONVERT(VarI4FromDate
, -1.0); EXPECT(-1);
1856 CONVERT(VarI4FromDate
, 0.0); EXPECT(0);
1857 CONVERT(VarI4FromDate
, 1.0); EXPECT(1);
1858 CONVERT(VarI4FromDate
, 2147483647.0); EXPECT(2147483647);
1859 CONVERT(VarI4FromDate
, 2147483648.0); EXPECT_OVERFLOW
;
1861 CONVERT(VarI4FromDate
, -1.5); EXPECT(-2);
1862 CONVERT(VarI4FromDate
, -0.6); EXPECT(-1);
1863 CONVERT(VarI4FromDate
, -0.5); EXPECT(0);
1864 CONVERT(VarI4FromDate
, -0.4); EXPECT(0);
1865 CONVERT(VarI4FromDate
, 0.4); EXPECT(0);
1866 CONVERT(VarI4FromDate
, 0.5); EXPECT(0);
1867 CONVERT(VarI4FromDate
, 0.6); EXPECT(1);
1868 CONVERT(VarI4FromDate
, 1.5); EXPECT(2);
1871 static void test_VarI4FromCy(void)
1875 CHECKPTR(VarI4FromCy
);
1876 CONVERT_CY(VarI4FromCy
,-1); EXPECT(-1);
1877 CONVERT_CY(VarI4FromCy
,0); EXPECT(0);
1878 CONVERT_CY(VarI4FromCy
,1); EXPECT(1);
1880 CONVERT_CY64(VarI4FromCy
,-1,2147483647ul); EXPECT_OVERFLOW
;
1881 CONVERT_CY64(VarI4FromCy
,-1,2147483648ul); EXPECT(-2147483647 - 1);
1882 CONVERT_CY64(VarI4FromCy
,0,2147483647ul); EXPECT(2147483647ul);
1883 CONVERT_CY64(VarI4FromCy
,0,2147483648ul); EXPECT_OVERFLOW
;
1885 CONVERT_CY(VarI4FromCy
,-1.5); EXPECT(-2);
1886 CONVERT_CY(VarI4FromCy
,-0.6); EXPECT(-1);
1887 CONVERT_CY(VarI4FromCy
,-0.5); EXPECT(0);
1888 CONVERT_CY(VarI4FromCy
,-0.4); EXPECT(0);
1889 CONVERT_CY(VarI4FromCy
,0.4); EXPECT(0);
1890 CONVERT_CY(VarI4FromCy
,0.5); EXPECT(0);
1891 CONVERT_CY(VarI4FromCy
,0.6); EXPECT(1);
1892 CONVERT_CY(VarI4FromCy
,1.5); EXPECT(2);
1895 static void test_VarI4FromDec(void)
1899 CHECKPTR(VarI4FromDec
);
1901 CONVERT_BADDEC(VarI4FromDec
);
1903 CONVERT_DEC(VarI4FromDec
,0,0x80,0,1); EXPECT(-1);
1904 CONVERT_DEC(VarI4FromDec
,0,0,0,0); EXPECT(0);
1905 CONVERT_DEC(VarI4FromDec
,0,0,0,1); EXPECT(1);
1907 CONVERT_DEC64(VarI4FromDec
,0,0x80,0,0,2147483649ul); EXPECT_OVERFLOW
;
1908 CONVERT_DEC64(VarI4FromDec
,0,0x80,0,0,2147483648ul); EXPECT(-2147483647 - 1);
1909 CONVERT_DEC64(VarI4FromDec
,0,0,0,0,2147483647ul); EXPECT(2147483647ul);
1910 CONVERT_DEC64(VarI4FromDec
,0,0,0,0,2147483648ul); EXPECT_OVERFLOW
;
1912 CONVERT_DEC64(VarI4FromDec
,2,0x80,0,50,100); EXPECT_OVERFLOW
;
1913 CONVERT_DEC64(VarI4FromDec
,2,0x80,0,50,0); EXPECT(-2147483647 - 1);
1914 CONVERT_DEC64(VarI4FromDec
,2,0,0,49,4294967196ul); EXPECT(2147483647);
1915 CONVERT_DEC64(VarI4FromDec
,2,0,0,50,0); EXPECT_OVERFLOW
;
1918 static void test_VarI4FromStr(void)
1923 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1925 CHECKPTR(VarI4FromStr
);
1927 CONVERT_STR(VarI4FromStr
,NULL
,0); EXPECT_MISMATCH
;
1928 CONVERT_STR(VarI4FromStr
,"0",0); EXPECT(0);
1929 CONVERT_STR(VarI4FromStr
,"-2147483649",0); EXPECT_OVERFLOW
;
1930 CONVERT_STR(VarI4FromStr
,"-2147483648",0); EXPECT(-2147483647 -1);
1931 CONVERT_STR(VarI4FromStr
,"2147483647",0); EXPECT(2147483647);
1932 CONVERT_STR(VarI4FromStr
,"2147483648",0); EXPECT_OVERFLOW
;
1935 CONVERT_STR(VarI4FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-2);
1936 CONVERT_STR(VarI4FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(-1);
1937 CONVERT_STR(VarI4FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1938 CONVERT_STR(VarI4FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1939 CONVERT_STR(VarI4FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1940 CONVERT_STR(VarI4FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
1941 CONVERT_STR(VarI4FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(1);
1942 CONVERT_STR(VarI4FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(2);
1945 static void test_VarI4Copy(void)
1947 COPYTEST(1, VT_I4
, V_I4(&vSrc
), V_I4(&vDst
), V_I4REF(&vSrc
), V_I4REF(&vDst
), "%d");
1950 static void test_VarI4ChangeTypeEx(void)
1954 VARIANTARG vSrc
, vDst
;
1958 INITIAL_TYPETEST(VT_I4
, V_I4
, "%d");
1960 NEGATIVE_TYPETEST(VT_I4
, V_I4
, "%d", VT_UI4
, V_UI4
);
1964 #define CONV_TYPE ULONG
1966 #define EXPECTRES(res, x) _EXPECTRES(res, x, "%u")
1968 static void test_VarUI4FromI1(void)
1970 CONVVARS(signed char);
1973 CHECKPTR(VarUI4FromI1
);
1974 OVERFLOWRANGE(VarUI4FromI1
, -127, 0);
1975 CONVERTRANGE(VarUI4FromI1
, 0, 128);
1978 static void test_VarUI4FromI2(void)
1983 CHECKPTR(VarUI4FromI2
);
1984 OVERFLOWRANGE(VarUI4FromI2
, -32768, 0);
1985 CONVERTRANGE(VarUI4FromI2
, 0, 32768);
1988 static void test_VarUI4FromUI2(void)
1993 CHECKPTR(VarUI4FromUI2
);
1994 CONVERTRANGE(VarUI4FromUI2
, 0, 65536);
1997 static void test_VarUI4FromI8(void)
2001 CHECKPTR(VarUI4FromI8
);
2002 CONVERT(VarUI4FromI8
, -1); EXPECT_OVERFLOW
;
2003 CONVERT(VarUI4FromI8
, 0); EXPECT(0);
2004 CONVERT(VarUI4FromI8
, 1); EXPECT(1);
2005 CONVERT(VarUI4FromI8
, 4294967295ul); EXPECT(4294967295ul);
2006 CONVERT_I8(VarUI4FromI8
, 1, 0); EXPECT_OVERFLOW
;
2009 static void test_VarUI4FromUI1(void)
2014 CHECKPTR(VarUI4FromUI1
);
2015 CONVERTRANGE(VarUI4FromUI1
, 0, 256);
2018 static void test_VarUI4FromI4(void)
2022 CHECKPTR(VarUI4FromI4
);
2023 CONVERT(VarUI4FromI4
, -1); EXPECT_OVERFLOW
;
2024 CONVERT(VarUI4FromI4
, 0); EXPECT(0);
2025 CONVERT(VarUI4FromI4
, 1); EXPECT(1);
2026 CONVERT(VarUI4FromI4
, 2147483647); EXPECT(2147483647);
2029 static void test_VarUI4FromUI8(void)
2033 CHECKPTR(VarUI4FromUI8
);
2034 CONVERT(VarUI4FromUI8
, 0); EXPECT(0);
2035 CONVERT(VarUI4FromUI8
, 1); EXPECT(1);
2036 CONVERT(VarUI4FromI8
, 4294967295ul); EXPECT(4294967295ul);
2037 CONVERT_I8(VarUI4FromI8
, 1, 0); EXPECT_OVERFLOW
;
2040 static void test_VarUI4FromBool(void)
2042 CONVVARS(VARIANT_BOOL
);
2045 CHECKPTR(VarUI4FromBool
);
2046 CONVERTRANGE(VarUI4FromBool
, -32768, 32768);
2049 static void test_VarUI4FromR4(void)
2053 CHECKPTR(VarUI4FromR4
);
2054 /* We can't test max values as they are not exactly representable in a float */
2055 CONVERT(VarUI4FromR4
, -1.0f
); EXPECT_OVERFLOW
;
2056 CONVERT(VarUI4FromR4
, -0.51f
); EXPECT_OVERFLOW
;
2057 CONVERT(VarUI4FromR4
, -0.5f
); EXPECT(0);
2058 CONVERT(VarUI4FromR4
, 0.0f
); EXPECT(0);
2059 CONVERT(VarUI4FromR4
, 1.0f
); EXPECT(1);
2061 CONVERT(VarUI4FromR4
, -1.5f
); EXPECT_OVERFLOW
;
2062 CONVERT(VarUI4FromR4
, -0.6f
); EXPECT_OVERFLOW
;
2063 CONVERT(VarUI4FromR4
, -0.5f
); EXPECT(0);
2064 CONVERT(VarUI4FromR4
, -0.4f
); EXPECT(0);
2065 CONVERT(VarUI4FromR4
, 0.4f
); EXPECT(0);
2066 CONVERT(VarUI4FromR4
, 0.5f
); EXPECT(0);
2067 CONVERT(VarUI4FromR4
, 0.6f
); EXPECT(1);
2068 CONVERT(VarUI4FromR4
, 1.5f
); EXPECT(2);
2072 static void test_VarUI4FromR8(void)
2076 CHECKPTR(VarUI4FromR8
);
2077 CONVERT(VarUI4FromR8
, -1.0); EXPECT_OVERFLOW
;
2078 CONVERT(VarUI4FromR4
, -0.51f
); EXPECT_OVERFLOW
;
2079 CONVERT(VarUI4FromR4
, -0.5f
); EXPECT(0);
2080 CONVERT(VarUI4FromR8
, 0.0); EXPECT(0);
2081 CONVERT(VarUI4FromR8
, 1.0); EXPECT(1);
2082 CONVERT(VarUI4FromR8
, 4294967295.0); EXPECT(4294967295ul);
2083 CONVERT(VarUI4FromR8
, 4294967295.49); EXPECT(4294967295ul);
2084 CONVERT(VarUI4FromR8
, 4294967295.5); EXPECT_OVERFLOW
;
2085 CONVERT(VarUI4FromR8
, 4294967296.0); EXPECT_OVERFLOW
;
2087 CONVERT(VarUI4FromR8
, -1.5); EXPECT_OVERFLOW
;
2088 CONVERT(VarUI4FromR8
, -0.6); EXPECT_OVERFLOW
;
2089 CONVERT(VarUI4FromR8
, -0.5); EXPECT(0);
2090 CONVERT(VarUI4FromR8
, -0.4); EXPECT(0);
2091 CONVERT(VarUI4FromR8
, 0.4); EXPECT(0);
2092 CONVERT(VarUI4FromR8
, 0.5); EXPECT(0);
2093 CONVERT(VarUI4FromR8
, 0.6); EXPECT(1);
2094 CONVERT(VarUI4FromR8
, 1.5); EXPECT(2);
2097 static void test_VarUI4FromDate(void)
2101 CHECKPTR(VarUI4FromDate
);
2102 CONVERT(VarUI4FromDate
, -1.0); EXPECT_OVERFLOW
;
2103 CONVERT(VarUI4FromDate
, 0.0); EXPECT(0);
2104 CONVERT(VarUI4FromDate
, 1.0); EXPECT(1);
2105 CONVERT(VarUI4FromDate
, 4294967295.0); EXPECT(4294967295ul);
2106 CONVERT(VarUI4FromDate
, 4294967296.0); EXPECT_OVERFLOW
;
2108 CONVERT(VarUI4FromDate
, -1.5); EXPECT_OVERFLOW
;
2109 CONVERT(VarUI4FromDate
, -0.6); EXPECT_OVERFLOW
;
2110 CONVERT(VarUI4FromDate
, -0.5); EXPECT(0);
2111 CONVERT(VarUI4FromDate
, -0.4); EXPECT(0);
2112 CONVERT(VarUI4FromDate
, 0.4); EXPECT(0);
2113 CONVERT(VarUI4FromDate
, 0.5); EXPECT(0);
2114 CONVERT(VarUI4FromDate
, 0.6); EXPECT(1);
2115 CONVERT(VarUI4FromDate
, 1.5); EXPECT(2);
2118 static void test_VarUI4FromCy(void)
2122 CHECKPTR(VarUI4FromCy
);
2123 CONVERT_CY(VarUI4FromCy
,-1); EXPECT_OVERFLOW
;
2124 CONVERT_CY(VarUI4FromCy
,0); EXPECT(0);
2125 CONVERT_CY(VarUI4FromCy
,1); EXPECT(1);
2126 CONVERT_CY64(VarUI4FromCy
,0,4294967295ul); EXPECT(4294967295ul);
2127 CONVERT_CY64(VarUI4FromCy
,1,0); EXPECT_OVERFLOW
;
2129 CONVERT_CY(VarUI4FromCy
,-1.5); EXPECT_OVERFLOW
;
2130 CONVERT_CY(VarUI4FromCy
,-0.6); EXPECT_OVERFLOW
;
2131 CONVERT_CY(VarUI4FromCy
,-0.5); EXPECT(0);
2132 CONVERT_CY(VarUI4FromCy
,-0.4); EXPECT(0);
2133 CONVERT_CY(VarUI4FromCy
,0.4); EXPECT(0);
2134 CONVERT_CY(VarUI4FromCy
,0.5); EXPECT(0);
2135 CONVERT_CY(VarUI4FromCy
,0.6); EXPECT(1);
2136 CONVERT_CY(VarUI4FromCy
,1.5); EXPECT(2);
2139 static void test_VarUI4FromDec(void)
2143 CHECKPTR(VarUI4FromDec
);
2145 CONVERT_BADDEC(VarUI4FromDec
);
2147 CONVERT_DEC(VarUI4FromDec
,0,0x80,0,1); EXPECT_OVERFLOW
;
2148 CONVERT_DEC(VarUI4FromDec
,0,0,0,0); EXPECT(0);
2149 CONVERT_DEC(VarUI4FromDec
,0,0,0,1); EXPECT(1);
2150 CONVERT_DEC64(VarUI4FromDec
,0,0,0,0,4294967295ul); EXPECT(4294967295ul);
2151 CONVERT_DEC64(VarUI4FromDec
,0,0,0,1,0); EXPECT_OVERFLOW
;
2153 CONVERT_DEC64(VarUI4FromDec
,2,0,0,99,4294967196ul); EXPECT(4294967295ul);
2154 CONVERT_DEC64(VarUI4FromDec
,2,0,0,100,0); EXPECT_OVERFLOW
;
2157 static void test_VarUI4FromStr(void)
2162 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
2164 CHECKPTR(VarUI4FromStr
);
2166 CONVERT_STR(VarUI4FromStr
,NULL
,0); EXPECT_MISMATCH
;
2167 CONVERT_STR(VarUI4FromStr
,"-1",0); EXPECT_OVERFLOW
;
2168 CONVERT_STR(VarUI4FromStr
,"0",0); EXPECT(0);
2169 CONVERT_STR(VarUI4FromStr
,"4294967295",0); EXPECT(4294967295ul);
2170 CONVERT_STR(VarUI4FromStr
,"4294967296",0); EXPECT_OVERFLOW
;
2173 CONVERT_STR(VarUI4FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
2174 CONVERT_STR(VarUI4FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
2175 CONVERT_STR(VarUI4FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
2176 CONVERT_STR(VarUI4FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
2177 CONVERT_STR(VarUI4FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
2178 CONVERT_STR(VarUI4FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0);
2179 CONVERT_STR(VarUI4FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(1);
2180 CONVERT_STR(VarUI4FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(2);
2183 static void test_VarUI4Copy(void)
2185 COPYTEST(1u, VT_UI4
, V_UI4(&vSrc
), V_UI4(&vDst
), V_UI4REF(&vSrc
), V_UI4REF(&vDst
), "%u");
2188 static void test_VarUI4ChangeTypeEx(void)
2192 VARIANTARG vSrc
, vDst
;
2196 INITIAL_TYPETEST(VT_UI4
, V_UI4
, "%u");
2198 NEGATIVE_TYPETEST(VT_UI4
, V_UI4
, "%u", VT_I4
, V_I4
);
2206 #define CONV_TYPE LONG64
2208 #define EXPECTI8(x) \
2209 ok((hres == S_OK && out == (CONV_TYPE)(x)), \
2210 "expected " #x "(%u,%u), got (%u,%u); hres=0x%08x\n", \
2211 (ULONG)((LONG64)(x) >> 32), (ULONG)((x) & 0xffffffff), \
2212 (ULONG)(out >> 32), (ULONG)(out & 0xffffffff), hres)
2214 #define EXPECTI864(x,y) \
2215 ok(hres == S_OK && (out >> 32) == (CONV_TYPE)(x) && (out & 0xffffffff) == (CONV_TYPE)(y), \
2216 "expected " #x "(%u,%u), got (%u,%u); hres=0x%08x\n", \
2217 (ULONG)(x), (ULONG)(y), \
2218 (ULONG)(out >> 32), (ULONG)(out & 0xffffffff), hres)
2220 static void test_VarI8FromI1(void)
2222 CONVVARS(signed char);
2225 CHECKPTR(VarI8FromI1
);
2226 for (i
= -128; i
< 128; i
++)
2228 CONVERT(VarI8FromI1
,i
); EXPECTI8(i
);
2232 static void test_VarI8FromUI1(void)
2237 CHECKPTR(VarI8FromUI1
);
2238 for (i
= 0; i
< 256; i
++)
2240 CONVERT(VarI8FromUI1
,i
); EXPECTI8(i
);
2244 static void test_VarI8FromI2(void)
2249 CHECKPTR(VarI8FromI2
);
2250 for (i
= -32768; i
< 32768; i
++)
2252 CONVERT(VarI8FromI2
,i
); EXPECTI8(i
);
2256 static void test_VarI8FromUI2(void)
2261 CHECKPTR(VarI8FromUI2
);
2262 for (i
= -0; i
< 65535; i
++)
2264 CONVERT(VarI8FromUI2
,i
); EXPECTI8(i
);
2268 static void test_VarI8FromUI4(void)
2272 CHECKPTR(VarI8FromUI4
);
2273 CONVERT(VarI8FromUI4
, 0); EXPECTI8(0);
2274 CONVERT(VarI8FromUI4
, 1); EXPECTI8(1);
2275 CONVERT(VarI8FromUI4
, 4294967295ul); EXPECTI8(4294967295ul);
2278 static void test_VarI8FromR4(void)
2282 CHECKPTR(VarI8FromR4
);
2284 CONVERT(VarI8FromR4
, -128.0f
); EXPECTI8(-128);
2285 CONVERT(VarI8FromR4
, -1.0f
); EXPECTI8(-1);
2286 CONVERT(VarI8FromR4
, 0.0f
); EXPECTI8(0);
2287 CONVERT(VarI8FromR4
, 1.0f
); EXPECTI8(1);
2288 CONVERT(VarI8FromR4
, 127.0f
); EXPECTI8(127);
2290 CONVERT(VarI8FromR4
, -1.5f
); EXPECTI8(-2);
2291 CONVERT(VarI8FromR4
, -0.6f
); EXPECTI8(-1);
2292 CONVERT(VarI8FromR4
, -0.5f
); EXPECTI8(0);
2293 CONVERT(VarI8FromR4
, -0.4f
); EXPECTI8(0);
2294 CONVERT(VarI8FromR4
, 0.4f
); EXPECTI8(0);
2295 CONVERT(VarI8FromR4
, 0.5f
); EXPECTI8(0);
2296 CONVERT(VarI8FromR4
, 0.6f
); EXPECTI8(1);
2297 CONVERT(VarI8FromR4
, 1.5f
); EXPECTI8(2);
2300 static void test_VarI8FromR8(void)
2304 CHECKPTR(VarI8FromR8
);
2305 CONVERT(VarI8FromR8
, -128.0); EXPECTI8(-128);
2306 CONVERT(VarI8FromR8
, -1.0); EXPECTI8(-1);
2307 CONVERT(VarI8FromR8
, 0.0); EXPECTI8(0);
2308 CONVERT(VarI8FromR8
, 1.0); EXPECTI8(1);
2309 CONVERT(VarI8FromR8
, 127.0); EXPECTI8(127);
2311 CONVERT(VarI8FromR8
, -1.5); EXPECTI8(-2);
2312 CONVERT(VarI8FromR8
, -0.6); EXPECTI8(-1);
2313 CONVERT(VarI8FromR8
, -0.5); EXPECTI8(0);
2314 CONVERT(VarI8FromR8
, -0.4); EXPECTI8(0);
2315 CONVERT(VarI8FromR8
, 0.4); EXPECTI8(0);
2316 CONVERT(VarI8FromR8
, 0.5); EXPECTI8(0);
2317 CONVERT(VarI8FromR8
, 0.6); EXPECTI8(1);
2318 CONVERT(VarI8FromR8
, 1.5); EXPECTI8(2);
2321 static void test_VarI8FromDate(void)
2325 CHECKPTR(VarI8FromDate
);
2326 CONVERT(VarI8FromDate
, -128.0); EXPECTI8(-128);
2327 CONVERT(VarI8FromDate
, -1.0); EXPECTI8(-1);
2328 CONVERT(VarI8FromDate
, 0.0); EXPECTI8(0);
2329 CONVERT(VarI8FromDate
, 1.0); EXPECTI8(1);
2330 CONVERT(VarI8FromDate
, 127.0); EXPECTI8(127);
2332 CONVERT(VarI8FromDate
, -1.5); EXPECTI8(-2);
2333 CONVERT(VarI8FromDate
, -0.6); EXPECTI8(-1);
2334 CONVERT(VarI8FromDate
, -0.5); EXPECTI8(0);
2335 CONVERT(VarI8FromDate
, -0.4); EXPECTI8(0);
2336 CONVERT(VarI8FromDate
, 0.4); EXPECTI8(0);
2337 CONVERT(VarI8FromDate
, 0.5); EXPECTI8(0);
2338 CONVERT(VarI8FromDate
, 0.6); EXPECTI8(1);
2339 CONVERT(VarI8FromDate
, 1.5); EXPECTI8(2);
2342 static void test_VarI8FromBool(void)
2344 CONVVARS(VARIANT_BOOL
);
2347 CHECKPTR(VarI8FromBool
);
2348 for (i
= -32768; i
< 32768; i
++)
2350 CONVERT(VarI8FromBool
,i
); EXPECTI8(i
);
2354 static void test_VarI8FromUI8(void)
2358 CHECKPTR(VarI8FromUI8
);
2359 CONVERT(VarI8FromUI8
, 0); EXPECTI8(0);
2360 CONVERT(VarI8FromUI8
, 1); EXPECTI8(1);
2361 CONVERT_I8(VarI8FromUI8
, 0x7fffffff, 0xffffffff); EXPECTI864(0x7fffffff, 0xffffffff);
2362 CONVERT_I8(VarI8FromUI8
, 0x80000000, 0); EXPECT_OVERFLOW
;
2365 static void test_VarI8FromCy(void)
2369 CHECKPTR(VarI8FromCy
);
2370 CONVERT_CY(VarI8FromCy
,-128); EXPECTI8(-129);
2371 CONVERT_CY(VarI8FromCy
,-1); EXPECTI8(-2);
2372 CONVERT_CY(VarI8FromCy
,0); EXPECTI8(0);
2373 CONVERT_CY(VarI8FromCy
,1); EXPECTI8(1);
2374 CONVERT_CY(VarI8FromCy
,127); EXPECTI8(127);
2376 CONVERT_CY(VarI8FromCy
,-1.5); EXPECTI8(-2);
2377 CONVERT_CY(VarI8FromCy
,-0.6); EXPECTI8(-1);
2378 CONVERT_CY(VarI8FromCy
,-0.5); EXPECTI8(-1);
2379 CONVERT_CY(VarI8FromCy
,-0.4); EXPECTI8(-1);
2380 CONVERT_CY(VarI8FromCy
,0.4); EXPECTI8(0);
2381 CONVERT_CY(VarI8FromCy
,0.5); EXPECTI8(0);
2382 CONVERT_CY(VarI8FromCy
,0.6); EXPECTI8(1);
2383 CONVERT_CY(VarI8FromCy
,1.5); EXPECTI8(2);
2386 static void test_VarI8FromDec(void)
2390 CHECKPTR(VarI8FromDec
);
2392 CONVERT_BADDEC(VarI8FromDec
);
2394 CONVERT_DEC(VarI8FromDec
,0,0x80,0,128); EXPECTI8(-128);
2395 CONVERT_DEC(VarI8FromDec
,0,0x80,0,1); EXPECTI8(-1);
2396 CONVERT_DEC(VarI8FromDec
,0,0,0,0); EXPECTI8(0);
2397 CONVERT_DEC(VarI8FromDec
,0,0,0,1); EXPECTI8(1);
2398 CONVERT_DEC(VarI8FromDec
,0,0,0,127); EXPECTI8(127);
2400 CONVERT_DEC(VarI8FromDec
,2,0x80,0,12700); EXPECTI8(-127);
2401 CONVERT_DEC(VarI8FromDec
,2,0,0,12700); EXPECTI8(127);
2404 static void test_VarI8FromStr(void)
2409 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
2411 CHECKPTR(VarI8FromStr
);
2413 CONVERT_STR(VarI8FromStr
,NULL
,0); EXPECT_MISMATCH
;
2414 CONVERT_STR(VarI8FromStr
,"0",0); EXPECTI8(0);
2415 CONVERT_STR(VarI8FromStr
,"-1",0); EXPECTI8(-1);
2416 CONVERT_STR(VarI8FromStr
,"2147483647",0); EXPECTI8(2147483647);
2418 CONVERT_STR(VarI8FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(-2);
2419 CONVERT_STR(VarI8FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECTI8(-1);
2420 CONVERT_STR(VarI8FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2421 CONVERT_STR(VarI8FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2422 CONVERT_STR(VarI8FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2423 CONVERT_STR(VarI8FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2424 CONVERT_STR(VarI8FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECTI8(1);
2425 CONVERT_STR(VarI8FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(2);
2428 static void test_VarI8Copy(void)
2431 VARIANTARG vSrc
, vDst
;
2436 win_skip("I8 and UI8 data types are not available\n");
2442 V_VT(&vSrc
) = VT_I8
;
2444 hres
= VariantCopy(&vDst
, &vSrc
);
2445 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I8
&& V_I8(&vDst
) == in
,
2446 "copy hres 0x%X, type %d, value (%x%08x) %x%08x\n",
2447 hres
, V_VT(&vDst
), (UINT
)(in
>> 32), (UINT
)in
, (UINT
)(V_I8(&vDst
) >> 32), (UINT
)V_I8(&vDst
) );
2448 V_VT(&vSrc
) = VT_I8
|VT_BYREF
;
2449 V_I8REF(&vSrc
) = &in
;
2450 hres
= VariantCopy(&vDst
, &vSrc
);
2451 ok(hres
== S_OK
&& V_VT(&vDst
) == (VT_I8
|VT_BYREF
) && V_I8REF(&vDst
) == &in
,
2452 "ref hres 0x%X, type %d, ref (%p) %p\n", hres
, V_VT(&vDst
), &in
, V_I8REF(&vDst
));
2453 hres
= VariantCopyInd(&vDst
, &vSrc
);
2454 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I8
&& V_I8(&vDst
) == in
,
2455 "copy hres 0x%X, type %d, value (%x%08x) %x%08x\n",
2456 hres
, V_VT(&vDst
), (UINT
)(in
>> 32), (UINT
)in
, (UINT
)(V_I8(&vDst
) >> 32), (UINT
)V_I8(&vDst
) );
2459 static void test_VarI8ChangeTypeEx(void)
2463 VARIANTARG vSrc
, vDst
;
2467 win_skip("I8 and UI8 data types are not available\n");
2473 INITIAL_TYPETESTI8(VT_I8
, V_I8
);
2477 /* Adapt the test macros to UI8 */
2479 #define CONV_TYPE ULONG64
2481 static void test_VarUI8FromI1(void)
2483 CONVVARS(signed char);
2486 CHECKPTR(VarUI8FromI1
);
2487 for (i
= -128; i
< 128; i
++)
2489 CONVERT(VarUI8FromI1
,i
);
2497 static void test_VarUI8FromUI1(void)
2502 CHECKPTR(VarUI8FromUI1
);
2503 for (i
= 0; i
< 256; i
++)
2505 CONVERT(VarUI8FromUI1
,i
); EXPECTI8(i
);
2509 static void test_VarUI8FromI2(void)
2514 CHECKPTR(VarUI8FromI2
);
2515 for (i
= -32768; i
< 32768; i
++)
2517 CONVERT(VarUI8FromI2
,i
);
2525 static void test_VarUI8FromUI2(void)
2530 CHECKPTR(VarUI8FromUI2
);
2531 for (i
= 0; i
< 65535; i
++)
2533 CONVERT(VarUI8FromUI2
,i
); EXPECTI8(i
);
2537 static void test_VarUI8FromUI4(void)
2541 CHECKPTR(VarUI8FromUI4
);
2542 CONVERT(VarUI8FromUI4
, 0); EXPECTI8(0);
2543 CONVERT(VarUI8FromUI4
, 0xffffffff); EXPECTI8(0xffffffff);
2546 static void test_VarUI8FromR4(void)
2550 CHECKPTR(VarUI8FromR4
);
2551 CONVERT(VarUI8FromR4
, -1.0f
); EXPECT_OVERFLOW
;
2552 CONVERT(VarUI8FromR4
, 0.0f
); EXPECTI8(0);
2553 CONVERT(VarUI8FromR4
, 1.0f
); EXPECTI8(1);
2554 CONVERT(VarUI8FromR4
, 255.0f
); EXPECTI8(255);
2556 CONVERT(VarUI8FromR4
, -1.5f
); EXPECT_OVERFLOW
;
2557 CONVERT(VarUI8FromR4
, -0.6f
); EXPECT_OVERFLOW
;
2558 CONVERT(VarUI8FromR4
, -0.5f
); EXPECTI8(0);
2559 CONVERT(VarUI8FromR4
, -0.4f
); EXPECTI8(0);
2560 CONVERT(VarUI8FromR4
, 0.4f
); EXPECTI8(0);
2561 CONVERT(VarUI8FromR4
, 0.5f
); EXPECTI8(0);
2562 CONVERT(VarUI8FromR4
, 0.6f
); EXPECTI8(1);
2563 CONVERT(VarUI8FromR4
, 1.5f
); EXPECTI8(2);
2566 static void test_VarUI8FromR8(void)
2570 CHECKPTR(VarUI8FromR8
);
2571 CONVERT(VarUI8FromR8
, -1.0); EXPECT_OVERFLOW
;
2572 CONVERT(VarUI8FromR8
, 0.0); EXPECTI8(0);
2573 CONVERT(VarUI8FromR8
, 1.0); EXPECTI8(1);
2574 CONVERT(VarUI8FromR8
, 255.0); EXPECTI8(255);
2576 CONVERT(VarUI8FromR8
, -1.5); EXPECT_OVERFLOW
;
2577 CONVERT(VarUI8FromR8
, -0.6); EXPECT_OVERFLOW
;
2578 CONVERT(VarUI8FromR8
, -0.5); EXPECTI8(0);
2579 CONVERT(VarUI8FromR8
, -0.4); EXPECTI8(0);
2580 CONVERT(VarUI8FromR8
, 0.4); EXPECTI8(0);
2581 CONVERT(VarUI8FromR8
, 0.5); EXPECTI8(0);
2582 CONVERT(VarUI8FromR8
, 0.6); EXPECTI8(1);
2583 CONVERT(VarUI8FromR8
, 1.5); EXPECTI8(2);
2586 static void test_VarUI8FromDate(void)
2590 CHECKPTR(VarUI8FromDate
);
2591 CONVERT(VarUI8FromDate
, -1.0); EXPECT_OVERFLOW
;
2592 CONVERT(VarUI8FromDate
, 0.0); EXPECTI8(0);
2593 CONVERT(VarUI8FromDate
, 1.0); EXPECTI8(1);
2594 CONVERT(VarUI8FromDate
, 255.0); EXPECTI8(255);
2596 CONVERT(VarUI8FromDate
, -1.5); EXPECT_OVERFLOW
;
2597 CONVERT(VarUI8FromDate
, -0.6); EXPECT_OVERFLOW
;
2598 CONVERT(VarUI8FromDate
, -0.5); EXPECTI8(0);
2599 CONVERT(VarUI8FromDate
, -0.4); EXPECTI8(0);
2600 CONVERT(VarUI8FromDate
, 0.4); EXPECTI8(0);
2601 CONVERT(VarUI8FromDate
, 0.5); EXPECTI8(0);
2602 CONVERT(VarUI8FromDate
, 0.6); EXPECTI8(1);
2603 CONVERT(VarUI8FromDate
, 1.5); EXPECTI8(2);
2606 static void test_VarUI8FromBool(void)
2608 CONVVARS(VARIANT_BOOL
);
2611 CHECKPTR(VarUI8FromBool
);
2612 for (i
= -32768; i
< 32768; i
++)
2614 CONVERT(VarUI8FromBool
, i
); EXPECTI8(i
);
2618 static void test_VarUI8FromI8(void)
2622 CHECKPTR(VarUI8FromI8
);
2623 CONVERT(VarUI8FromI8
, -1); EXPECT_OVERFLOW
;
2624 CONVERT(VarUI8FromI8
, 0); EXPECTI8(0);
2625 CONVERT(VarUI8FromI8
, 1); EXPECTI8(1);
2628 static void test_VarUI8FromCy(void)
2632 CHECKPTR(VarUI8FromCy
);
2633 CONVERT_CY(VarUI8FromCy
,-1); EXPECT_OVERFLOW
;
2634 CONVERT_CY(VarUI8FromCy
,0); EXPECTI8(0);
2635 CONVERT_CY(VarUI8FromCy
,1); EXPECTI8(1);
2636 CONVERT_CY(VarUI8FromCy
,255); EXPECTI8(255);
2638 CONVERT_CY(VarUI8FromCy
,-1.5); EXPECT_OVERFLOW
;
2639 CONVERT_CY(VarUI8FromCy
,-0.6); EXPECT_OVERFLOW
;
2640 CONVERT_CY(VarUI8FromCy
,-0.5); EXPECTI8(0);
2641 CONVERT_CY(VarUI8FromCy
,-0.4); EXPECTI8(0);
2642 CONVERT_CY(VarUI8FromCy
,0.4); EXPECTI8(0);
2643 CONVERT_CY(VarUI8FromCy
,0.5); EXPECTI8(0);
2644 CONVERT_CY(VarUI8FromCy
,0.6); EXPECTI8(1);
2645 CONVERT_CY(VarUI8FromCy
,1.5); EXPECTI8(2);
2648 static void test_VarUI8FromDec(void)
2652 CHECKPTR(VarUI8FromDec
);
2654 CONVERT_BADDEC(VarUI8FromDec
);
2656 /* This returns 1 under native; Wine fixes this bug and returns overflow */
2659 CONVERT_DEC(VarUI8FromDec
,0,0x80,0,1);
2662 CONVERT_DEC(VarUI8FromDec
,0,0,0,0); EXPECTI8(0);
2663 CONVERT_DEC(VarUI8FromDec
,0,0,0,1); EXPECTI8(1);
2664 CONVERT_DEC(VarUI8FromDec
,0,0,0,255); EXPECTI8(255);
2666 CONVERT_DEC(VarUI8FromDec
,2,0x80,0,100); EXPECT_OVERFLOW
;
2667 CONVERT_DEC(VarUI8FromDec
,2,0,0,25500); EXPECTI8(255);
2670 static void test_VarUI8FromStr(void)
2675 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
2677 CHECKPTR(VarUI8FromStr
);
2679 CONVERT_STR(VarUI8FromStr
,NULL
,0); EXPECT_MISMATCH
;
2680 CONVERT_STR(VarUI8FromStr
,"0",0); EXPECTI8(0);
2681 CONVERT_STR(VarUI8FromStr
,"-1",0); EXPECT_OVERFLOW
;
2682 CONVERT_STR(VarUI8FromStr
,"2147483647",0); EXPECTI8(2147483647);
2683 CONVERT_STR(VarUI8FromStr
,"18446744073709551614",0); EXPECTI864(0xFFFFFFFF,0xFFFFFFFE);
2684 CONVERT_STR(VarUI8FromStr
,"18446744073709551615",0); EXPECTI864(0xFFFFFFFF,0xFFFFFFFF);
2685 CONVERT_STR(VarUI8FromStr
,"18446744073709551616",0); EXPECT_OVERFLOW
;
2687 CONVERT_STR(VarUI8FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
2688 CONVERT_STR(VarUI8FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT_OVERFLOW
;
2689 CONVERT_STR(VarUI8FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2690 CONVERT_STR(VarUI8FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2691 CONVERT_STR(VarUI8FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2692 CONVERT_STR(VarUI8FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(0);
2693 CONVERT_STR(VarUI8FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECTI8(1);
2694 CONVERT_STR(VarUI8FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECTI8(2);
2697 static void test_VarUI8Copy(void)
2700 VARIANTARG vSrc
, vDst
;
2705 win_skip("I8 and UI8 data types are not available\n");
2711 V_VT(&vSrc
) = VT_UI8
;
2713 hres
= VariantCopy(&vDst
, &vSrc
);
2714 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_UI8
&& V_UI8(&vDst
) == in
,
2715 "copy hres 0x%X, type %d, value (%x%08x) %x%08x\n",
2716 hres
, V_VT(&vDst
), (UINT
)(in
>> 32), (UINT
)in
, (UINT
)(V_UI8(&vDst
) >> 32), (UINT
)V_UI8(&vDst
) );
2717 V_VT(&vSrc
) = VT_UI8
|VT_BYREF
;
2718 V_UI8REF(&vSrc
) = &in
;
2719 hres
= VariantCopy(&vDst
, &vSrc
);
2720 ok(hres
== S_OK
&& V_VT(&vDst
) == (VT_UI8
|VT_BYREF
) && V_UI8REF(&vDst
) == &in
,
2721 "ref hres 0x%X, type %d, ref (%p) %p\n", hres
, V_VT(&vDst
), &in
, V_UI8REF(&vDst
));
2722 hres
= VariantCopyInd(&vDst
, &vSrc
);
2723 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_UI8
&& V_UI8(&vDst
) == in
,
2724 "copy hres 0x%X, type %d, value (%x%08x) %x%08x\n",
2725 hres
, V_VT(&vDst
), (UINT
)(in
>> 32), (UINT
)in
, (UINT
)(V_UI8(&vDst
) >> 32), (UINT
)V_UI8(&vDst
) );
2728 static void test_VarUI8ChangeTypeEx(void)
2732 VARIANTARG vSrc
, vDst
;
2736 win_skip("I8 and UI8 data types are not available\n");
2742 INITIAL_TYPETESTI8(VT_UI8
, V_UI8
);
2751 #define CONV_TYPE float
2753 #define EXPECTRES(res, x) _EXPECTRES(res, x, "%15.15f")
2755 static void test_VarR4FromI1(void)
2757 CONVVARS(signed char);
2760 CHECKPTR(VarR4FromI1
);
2761 CONVERTRANGE(VarR4FromI1
, -128, 128);
2764 static void test_VarR4FromUI1(void)
2769 CHECKPTR(VarR4FromUI1
);
2770 CONVERTRANGE(VarR4FromUI1
, 0, 256);
2773 static void test_VarR4FromI2(void)
2778 CHECKPTR(VarR4FromI2
);
2779 CONVERTRANGE(VarR4FromI2
, -32768, 32768);
2782 static void test_VarR4FromUI2(void)
2787 CHECKPTR(VarR4FromUI2
);
2788 CONVERTRANGE(VarR4FromUI2
, 0, 65536);
2791 static void test_VarR4FromI4(void)
2795 CHECKPTR(VarR4FromI4
);
2796 CONVERT(VarR4FromI4
, -2147483647-1); EXPECT(-2147483648.0f
);
2797 CONVERT(VarR4FromI4
, -1); EXPECT(-1.0f
);
2798 CONVERT(VarR4FromI4
, 0); EXPECT(0.0f
);
2799 CONVERT(VarR4FromI4
, 1); EXPECT(1.0f
);
2800 CONVERT(VarR4FromI4
, 2147483647); EXPECT(2147483647.0f
);
2803 static void test_VarR4FromUI4(void)
2805 CONVVARS(unsigned int);
2807 CHECKPTR(VarR4FromUI4
);
2808 CONVERT(VarR4FromUI4
, 0); EXPECT(0.0f
);
2809 CONVERT(VarR4FromUI4
, 1); EXPECT(1.0f
);
2810 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
2811 CONVERT(VarR4FromUI4
, 0xffffffff); EXPECT(4294967296.0f
);
2815 static void test_VarR4FromR8(void)
2819 CHECKPTR(VarR4FromR8
);
2820 CONVERT(VarR4FromR8
, -1.0); EXPECT(-1.0f
);
2821 CONVERT(VarR4FromR8
, 0.0); EXPECT(0.0f
);
2822 CONVERT(VarR4FromR8
, 1.0); EXPECT(1.0f
);
2823 CONVERT(VarR4FromR8
, 1.5); EXPECT(1.5f
);
2825 /* Skip rounding tests - no rounding is done */
2828 static void test_VarR4FromBool(void)
2830 CONVVARS(VARIANT_BOOL
);
2832 CHECKPTR(VarR4FromBool
);
2833 CONVERT(VarR4FromBool
, VARIANT_TRUE
); EXPECT(VARIANT_TRUE
* 1.0f
);
2834 CONVERT(VarR4FromBool
, VARIANT_FALSE
); EXPECT(VARIANT_FALSE
* 1.0f
);
2837 static void test_VarR4FromCy(void)
2841 CHECKPTR(VarR4FromCy
);
2842 CONVERT_CY(VarR4FromCy
,-32768); EXPECT(-32768.0f
);
2843 CONVERT_CY(VarR4FromCy
,-1); EXPECT(-1.0f
);
2844 CONVERT_CY(VarR4FromCy
,0); EXPECT(0.0f
);
2845 CONVERT_CY(VarR4FromCy
,1); EXPECT(1.0f
);
2846 CONVERT_CY(VarR4FromCy
,32768); EXPECT(32768.0f
);
2848 CONVERT_CY(VarR4FromCy
,-1.5); EXPECT(-1.5f
);
2849 CONVERT_CY(VarR4FromCy
,-0.6); EXPECT(-0.6f
);
2850 CONVERT_CY(VarR4FromCy
,-0.5); EXPECT(-0.5f
);
2851 CONVERT_CY(VarR4FromCy
,-0.4); EXPECT(-0.4f
);
2852 CONVERT_CY(VarR4FromCy
,0.4); EXPECT(0.4f
);
2853 CONVERT_CY(VarR4FromCy
,0.5); EXPECT(0.5f
);
2854 CONVERT_CY(VarR4FromCy
,0.6); EXPECT(0.6f
);
2855 CONVERT_CY(VarR4FromCy
,1.5); EXPECT(1.5f
);
2858 static void test_VarR4FromI8(void)
2862 CHECKPTR(VarR4FromI8
);
2863 CONVERT(VarR4FromI8
, -1); EXPECT(-1.0f
);
2864 CONVERT(VarR4FromI8
, 0); EXPECT(0.0f
);
2865 CONVERT(VarR4FromI8
, 1); EXPECT(1.0f
);
2868 static void test_VarR4FromUI8(void)
2872 CHECKPTR(VarR4FromUI8
);
2873 CONVERT(VarR4FromUI8
, 0); EXPECT(0.0f
);
2874 CONVERT(VarR4FromUI8
, 1); EXPECT(1.0f
);
2877 static void test_VarR4FromDec(void)
2881 CHECKPTR(VarR4FromDec
);
2883 CONVERT_BADDEC(VarR4FromDec
);
2885 CONVERT_DEC(VarR4FromDec
,0,0x80,0,32768); EXPECT(-32768.0f
);
2886 CONVERT_DEC(VarR4FromDec
,0,0x80,0,1); EXPECT(-1.0f
);
2887 CONVERT_DEC(VarR4FromDec
,0,0,0,0); EXPECT(0.0f
);
2888 CONVERT_DEC(VarR4FromDec
,0,0,0,1); EXPECT(1.0f
);
2889 CONVERT_DEC(VarR4FromDec
,0,0,0,32767); EXPECT(32767.0f
);
2891 CONVERT_DEC(VarR4FromDec
,2,0x80,0,3276800); EXPECT(-32768.0f
);
2892 CONVERT_DEC(VarR4FromDec
,2,0,0,3276700); EXPECT(32767.0f
);
2894 CONVERT_DEC(VarR4FromDec
,0,0,1,0); EXPECT(18446744073709551616.0f
);
2897 static void test_VarR4FromDate(void)
2901 CHECKPTR(VarR4FromDate
);
2902 CONVERT(VarR4FromDate
, -1.0); EXPECT(-1.0f
);
2903 CONVERT(VarR4FromDate
, 0.0); EXPECT(0.0f
);
2904 CONVERT(VarR4FromDate
, 1.0); EXPECT(1.0f
);
2907 static void test_VarR4FromStr(void)
2912 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
2914 CHECKPTR(VarR4FromStr
);
2916 CONVERT_STR(VarR4FromStr
,NULL
,0); EXPECT_MISMATCH
;
2917 CONVERT_STR(VarR4FromStr
,"-1", 0); EXPECT(-1.0f
);
2918 CONVERT_STR(VarR4FromStr
,"0", 0); EXPECT(0.0f
);
2919 CONVERT_STR(VarR4FromStr
,"1", 0); EXPECT(1.0f
);
2921 CONVERT_STR(VarR4FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-1.5f
);
2922 CONVERT_STR(VarR4FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.6f
);
2923 CONVERT_STR(VarR4FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.5f
);
2924 CONVERT_STR(VarR4FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.4f
);
2925 CONVERT_STR(VarR4FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0.4f
);
2926 CONVERT_STR(VarR4FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0.5f
);
2927 CONVERT_STR(VarR4FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(0.6f
);
2928 CONVERT_STR(VarR4FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(1.5f
);
2931 static void test_VarR4Copy(void)
2933 COPYTEST(77665544.0f
, VT_R4
, V_R4(&vSrc
), V_R4(&vDst
), V_R4REF(&vSrc
),V_R4REF(&vDst
), "%15.15f");
2936 static void test_VarR4ChangeTypeEx(void)
2938 #ifdef HAS_UINT64_TO_FLOAT
2941 VARIANTARG vSrc
, vDst
;
2945 INITIAL_TYPETEST(VT_R4
, V_R4
, "%f");
2955 #define CONV_TYPE double
2957 static void test_VarR8FromI1(void)
2959 CONVVARS(signed char);
2962 CHECKPTR(VarR8FromI1
);
2963 CONVERTRANGE(VarR8FromI1
, -128, 128);
2966 static void test_VarR8FromUI1(void)
2971 CHECKPTR(VarR8FromUI1
);
2972 CONVERTRANGE(VarR8FromUI1
, 0, 256);
2975 static void test_VarR8FromI2(void)
2980 CHECKPTR(VarR8FromI2
);
2981 CONVERTRANGE(VarR8FromI2
, -32768, 32768);
2984 static void test_VarR8FromUI2(void)
2989 CHECKPTR(VarR8FromUI2
);
2990 CONVERTRANGE(VarR8FromUI2
, 0, 65536);
2993 static void test_VarR8FromI4(void)
2997 CHECKPTR(VarR8FromI4
);
2998 CONVERT(VarR8FromI4
, -2147483647-1); EXPECT(-2147483648.0);
2999 CONVERT(VarR8FromI4
, -1); EXPECT(-1.0);
3000 CONVERT(VarR8FromI4
, 0); EXPECT(0.0);
3001 CONVERT(VarR8FromI4
, 1); EXPECT(1.0);
3002 CONVERT(VarR8FromI4
, 0x7fffffff); EXPECT(2147483647.0);
3005 static void test_VarR8FromUI4(void)
3007 CONVVARS(unsigned int);
3009 CHECKPTR(VarR8FromUI4
);
3010 CONVERT(VarR8FromUI4
, 0); EXPECT(0.0);
3011 CONVERT(VarR8FromUI4
, 1); EXPECT(1.0);
3012 CONVERT(VarR8FromUI4
, 0xffffffff); EXPECT(4294967295.0);
3015 static void test_VarR8FromR4(void)
3019 CHECKPTR(VarR8FromR4
);
3020 CONVERT(VarR8FromR4
, -1.0f
); EXPECT(-1.0);
3021 CONVERT(VarR8FromR4
, 0.0f
); EXPECT(0.0);
3022 CONVERT(VarR8FromR4
, 1.0f
); EXPECT(1.0);
3023 CONVERT(VarR8FromR4
, 1.5f
); EXPECT(1.5);
3025 /* Skip rounding tests - no rounding is done */
3028 static void test_VarR8FromBool(void)
3030 CONVVARS(VARIANT_BOOL
);
3032 CHECKPTR(VarR8FromBool
);
3033 CONVERT(VarR8FromBool
, VARIANT_TRUE
); EXPECT(VARIANT_TRUE
* 1.0);
3034 CONVERT(VarR8FromBool
, VARIANT_FALSE
); EXPECT(VARIANT_FALSE
* 1.0);
3037 static void test_VarR8FromCy(void)
3041 CHECKPTR(VarR8FromCy
);
3042 CONVERT_CY(VarR8FromCy
,-32769); EXPECT(-32769.0);
3043 CONVERT_CY(VarR8FromCy
,-32768); EXPECT(-32768.0);
3044 CONVERT_CY(VarR8FromCy
,-1); EXPECT(-1.0);
3045 CONVERT_CY(VarR8FromCy
,0); EXPECT(0.0);
3046 CONVERT_CY(VarR8FromCy
,1); EXPECT(1.0);
3047 CONVERT_CY(VarR8FromCy
,32767); EXPECT(32767.0);
3048 CONVERT_CY(VarR8FromCy
,32768); EXPECT(32768.0);
3050 CONVERT_CY(VarR8FromCy
,-1.5); EXPECT(-1.5);
3051 CONVERT_CY(VarR8FromCy
,-0.6); EXPECT(-0.6);
3052 CONVERT_CY(VarR8FromCy
,-0.5); EXPECT(-0.5);
3053 CONVERT_CY(VarR8FromCy
,-0.4); EXPECT(-0.4);
3054 CONVERT_CY(VarR8FromCy
,0.4); EXPECT(0.4);
3055 CONVERT_CY(VarR8FromCy
,0.5); EXPECT(0.5);
3056 CONVERT_CY(VarR8FromCy
,0.6); EXPECT(0.6);
3057 CONVERT_CY(VarR8FromCy
,1.5); EXPECT(1.5);
3060 static void test_VarR8FromI8(void)
3064 CHECKPTR(VarR8FromI8
);
3065 CONVERT(VarR8FromI8
, -1); EXPECT(-1.0);
3066 CONVERT(VarR8FromI8
, 0); EXPECT(0.0);
3067 CONVERT(VarR8FromI8
, 1); EXPECT(1.0);
3068 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3069 CONVERT_I8(VarR8FromI8
, 0x7fffffff,0xffffffff); EXPECT(9223372036854775808.0);
3073 static void test_VarR8FromUI8(void)
3077 CHECKPTR(VarR8FromUI8
);
3078 CONVERT(VarR8FromUI8
, 0); EXPECT(0.0);
3079 CONVERT(VarR8FromUI8
, 1); EXPECT(1.0);
3080 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3081 CONVERT_I8(VarR8FromUI8
, 0x80000000,0); EXPECT(9223372036854775808.0);
3085 static void test_VarR8FromDec(void)
3089 CHECKPTR(VarR8FromDec
);
3091 CONVERT_BADDEC(VarR8FromDec
);
3093 CONVERT_DEC(VarR8FromDec
,0,0x80,0,32768); EXPECT(-32768.0);
3094 CONVERT_DEC(VarR8FromDec
,0,0x80,0,1); EXPECT(-1.0);
3095 CONVERT_DEC(VarR8FromDec
,0,0,0,0); EXPECT(0.0);
3096 CONVERT_DEC(VarR8FromDec
,0,0,0,1); EXPECT(1.0);
3097 CONVERT_DEC(VarR8FromDec
,0,0,0,32767); EXPECT(32767.0);
3099 CONVERT_DEC(VarR8FromDec
,2,0x80,0,3276800); EXPECT(-32768.0);
3100 CONVERT_DEC(VarR8FromDec
,2,0,0,3276700); EXPECT(32767.0);
3102 CONVERT_DEC(VarR8FromDec
,0,0,1,0); EXPECT(18446744073709551616.0);
3105 static void test_VarR8FromDate(void)
3109 CHECKPTR(VarR8FromDate
);
3110 CONVERT(VarR8FromDate
, -1.0); EXPECT(-1.0);
3111 CONVERT(VarR8FromDate
, -0.0); EXPECT(0.0);
3112 CONVERT(VarR8FromDate
, 1.0); EXPECT(1.0);
3115 static void test_VarR8FromStr(void)
3120 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3122 CHECKPTR(VarR8FromStr
);
3124 CONVERT_STR(VarR8FromStr
,NULL
,0); EXPECT_MISMATCH
;
3125 CONVERT_STR(VarR8FromStr
,"",0); EXPECT_MISMATCH
;
3126 CONVERT_STR(VarR8FromStr
," ",0); EXPECT_MISMATCH
;
3128 CONVERT_STR(VarR8FromStr
,"0",LOCALE_NOUSEROVERRIDE
); EXPECT(0.0);
3129 CONVERT_STR(VarR8FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-1.5);
3130 CONVERT_STR(VarR8FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.6);
3131 CONVERT_STR(VarR8FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.5);
3132 CONVERT_STR(VarR8FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.4);
3133 CONVERT_STR(VarR8FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0.4);
3134 CONVERT_STR(VarR8FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0.5);
3135 CONVERT_STR(VarR8FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(0.6);
3136 CONVERT_STR(VarR8FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(1.5);
3138 /* We already have exhaustive tests for number parsing, so skip those tests here */
3141 static void test_VarR8Copy(void)
3143 COPYTEST(77665544.0, VT_R8
, V_R8(&vSrc
), V_R8(&vDst
), V_R8REF(&vSrc
),V_R8REF(&vDst
), "%16.16g");
3146 static void test_VarR8ChangeTypeEx(void)
3148 #ifdef HAS_UINT64_TO_FLOAT
3151 VARIANTARG vSrc
, vDst
;
3155 INITIAL_TYPETEST(VT_R8
, V_R8
, "%g");
3160 #define MATHRND(l, r) left = l; right = r; hres = pVarR8Round(left, right, &out)
3162 static void test_VarR8Round(void)
3165 double left
= 0.0, out
;
3168 CHECKPTR(VarR8Round
);
3169 MATHRND(0.5432, 5); EXPECT(0.5432);
3170 MATHRND(0.5432, 4); EXPECT(0.5432);
3171 MATHRND(0.5432, 3); EXPECT(0.543);
3172 MATHRND(0.5432, 2); EXPECT(0.54);
3173 MATHRND(0.5432, 1); EXPECT(0.5);
3174 MATHRND(0.5532, 0); EXPECT(1);
3175 MATHRND(0.5532, -1); EXPECT_INVALID
;
3177 MATHRND(0.5568, 5); EXPECT(0.5568);
3178 MATHRND(0.5568, 4); EXPECT(0.5568);
3179 MATHRND(0.5568, 3); EXPECT(0.557);
3180 MATHRND(0.5568, 2); EXPECT(0.56);
3181 MATHRND(0.5568, 1); EXPECT(0.6);
3182 MATHRND(0.5568, 0); EXPECT(1);
3183 MATHRND(0.5568, -1); EXPECT_INVALID
;
3185 MATHRND(0.4999, 0); EXPECT(0);
3186 MATHRND(0.5000, 0); EXPECT(0);
3187 MATHRND(0.5001, 0); EXPECT(1);
3188 MATHRND(1.4999, 0); EXPECT(1);
3189 MATHRND(1.5000, 0); EXPECT(2);
3190 MATHRND(1.5001, 0); EXPECT(2);
3198 #define CONV_TYPE DATE
3200 static void test_VarDateFromI1(void)
3202 CONVVARS(signed char);
3205 CHECKPTR(VarDateFromI1
);
3206 CONVERTRANGE(VarDateFromI1
, -128, 128);
3209 static void test_VarDateFromUI1(void)
3214 CHECKPTR(VarDateFromUI1
);
3215 CONVERTRANGE(VarDateFromUI1
, 0, 256);
3218 static void test_VarDateFromI2(void)
3223 CHECKPTR(VarDateFromI2
);
3224 CONVERTRANGE(VarDateFromI2
, -32768, 32768);
3227 static void test_VarDateFromUI2(void)
3232 CHECKPTR(VarDateFromUI2
);
3233 CONVERTRANGE(VarDateFromUI2
, 0, 65536);
3236 static void test_VarDateFromI4(void)
3240 CHECKPTR(VarDateFromI4
);
3241 CONVERT(VarDateFromI4
, DATE_MIN
-1);
3242 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3244 CONVERT(VarDateFromI4
, DATE_MIN
); EXPECT(DATE_MIN
);
3245 CONVERT(VarDateFromI4
, -1); EXPECT(-1.0);
3246 CONVERT(VarDateFromI4
, 0); EXPECT(0.0);
3247 CONVERT(VarDateFromI4
, 1); EXPECT(1.0);
3248 CONVERT(VarDateFromI4
, DATE_MAX
); EXPECT(DATE_MAX
);
3249 CONVERT(VarDateFromI4
, DATE_MAX
+1);
3250 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3254 static void test_VarDateFromUI4(void)
3256 CONVVARS(unsigned int);
3258 CHECKPTR(VarDateFromUI4
);
3259 CONVERT(VarDateFromUI4
, 0); EXPECT(0.0);
3260 CONVERT(VarDateFromUI4
, 1); EXPECT(1.0);
3261 CONVERT(VarDateFromUI4
, DATE_MAX
); EXPECT(DATE_MAX
);
3262 CONVERT(VarDateFromUI4
, DATE_MAX
+1);
3263 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3267 static void test_VarDateFromR4(void)
3271 CHECKPTR(VarDateFromR4
);
3272 CONVERT(VarDateFromR4
, -1.0f
); EXPECT(-1.0);
3273 CONVERT(VarDateFromR4
, 0.0f
); EXPECT(0.0);
3274 CONVERT(VarDateFromR4
, 1.0f
); EXPECT(1.0);
3275 CONVERT(VarDateFromR4
, 1.5f
); EXPECT(1.5);
3278 static void test_VarDateFromR8(void)
3282 CHECKPTR(VarDateFromR8
);
3283 CONVERT(VarDateFromR8
, -1.0f
); EXPECT(-1.0);
3284 CONVERT(VarDateFromR8
, 0.0f
); EXPECT(0.0);
3285 CONVERT(VarDateFromR8
, 1.0f
); EXPECT(1.0);
3286 CONVERT(VarDateFromR8
, 1.5f
); EXPECT(1.5);
3289 static void test_VarDateFromBool(void)
3291 CONVVARS(VARIANT_BOOL
);
3293 CHECKPTR(VarDateFromBool
);
3294 CONVERT(VarDateFromBool
, VARIANT_TRUE
); EXPECT(VARIANT_TRUE
* 1.0);
3295 CONVERT(VarDateFromBool
, VARIANT_FALSE
); EXPECT(VARIANT_FALSE
* 1.0);
3298 static void test_VarDateFromCy(void)
3302 CHECKPTR(VarDateFromCy
);
3303 CONVERT_CY(VarDateFromCy
,-32769); EXPECT(-32769.0);
3304 CONVERT_CY(VarDateFromCy
,-32768); EXPECT(-32768.0);
3305 CONVERT_CY(VarDateFromCy
,-1); EXPECT(-1.0);
3306 CONVERT_CY(VarDateFromCy
,0); EXPECT(0.0);
3307 CONVERT_CY(VarDateFromCy
,1); EXPECT(1.0);
3308 CONVERT_CY(VarDateFromCy
,32767); EXPECT(32767.0);
3309 CONVERT_CY(VarDateFromCy
,32768); EXPECT(32768.0);
3311 CONVERT_CY(VarDateFromCy
,-1.5); EXPECT(-1.5);
3312 CONVERT_CY(VarDateFromCy
,-0.6); EXPECT(-0.6);
3313 CONVERT_CY(VarDateFromCy
,-0.5); EXPECT(-0.5);
3314 CONVERT_CY(VarDateFromCy
,-0.4); EXPECT(-0.4);
3315 CONVERT_CY(VarDateFromCy
,0.4); EXPECT(0.4);
3316 CONVERT_CY(VarDateFromCy
,0.5); EXPECT(0.5);
3317 CONVERT_CY(VarDateFromCy
,0.6); EXPECT(0.6);
3318 CONVERT_CY(VarDateFromCy
,1.5); EXPECT(1.5);
3321 static void test_VarDateFromI8(void)
3325 CHECKPTR(VarDateFromI8
);
3326 CONVERT(VarDateFromI8
, DATE_MIN
-1); EXPECT_OVERFLOW
;
3327 CONVERT(VarDateFromI8
, DATE_MIN
); EXPECT(DATE_MIN
);
3328 CONVERT(VarDateFromI8
, -1); EXPECT(-1.0);
3329 CONVERT(VarDateFromI8
, 0); EXPECT(0.0);
3330 CONVERT(VarDateFromI8
, 1); EXPECT(1.0);
3331 CONVERT(VarDateFromI8
, DATE_MAX
); EXPECT(DATE_MAX
);
3332 CONVERT(VarDateFromI8
, DATE_MAX
+1); EXPECT_OVERFLOW
;
3335 static void test_VarDateFromUI8(void)
3339 CHECKPTR(VarDateFromUI8
);
3340 CONVERT(VarDateFromUI8
, 0); EXPECT(0.0);
3341 CONVERT(VarDateFromUI8
, 1); EXPECT(1.0);
3342 CONVERT(VarDateFromUI8
, DATE_MAX
); EXPECT(DATE_MAX
);
3343 CONVERT(VarDateFromUI8
, DATE_MAX
+1); EXPECT_OVERFLOW
;
3346 static void test_VarDateFromDec(void)
3350 CHECKPTR(VarDateFromDec
);
3352 CONVERT_BADDEC(VarDateFromDec
);
3354 CONVERT_DEC(VarDateFromDec
,0,0x80,0,32768); EXPECT(-32768.0);
3355 CONVERT_DEC(VarDateFromDec
,0,0x80,0,1); EXPECT(-1.0);
3356 CONVERT_DEC(VarDateFromDec
,0,0,0,0); EXPECT(0.0);
3357 CONVERT_DEC(VarDateFromDec
,0,0,0,1); EXPECT(1.0);
3358 CONVERT_DEC(VarDateFromDec
,0,0,0,32767); EXPECT(32767.0);
3360 CONVERT_DEC(VarDateFromDec
,2,0x80,0,3276800); EXPECT(-32768.0);
3361 CONVERT_DEC(VarDateFromDec
,2,0,0,3276700); EXPECT(32767.0);
3365 buff[0] = '\0'; out = 0.0; \
3366 if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
3367 hres = pVarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
3369 #define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \
3370 pSystemTimeToVariantTime(&st,&relative)
3372 static const char * const BadDateStrings
[] =
3374 "True", "False", /* Plain text */
3375 "0.", ".0", "-1.1", "1.1-", /* Partial specifications */
3376 "1;2;3", "1*2*3", "1@2@3", "1#2#3", "(1:2)","<1:2>","1|2|3", /* Bad chars */
3377 "0", "1", /* 1 element */
3378 "0.60", "24.00", "0:60", "24:00", "1 2 am", "1 am 2", /* 2 elements */
3379 "1.5 2", "1 5.2", "2 32 3", "1 2 am 3", /* 3 elements */
3380 "1 2.3 4", "1.2.3 4", "1 2.3.4", "1.2 3.4", "1.2.3.4", "1 2 3 4",
3381 "1 am 2 3.4", "1 2 am 3.4", "1.2 3 am 4", "1.2 3 4 am", /* 4 elements */
3382 "1.2.3.4.5", "1.2.3.4 5", "1.2.3 4.5", "1.2 3.4.5", "1.2 3.4 5", "1.2 3 4.5",
3383 "1 2.3.4.5", "1 2.3.4 5", "1 2.3 4.5", "1 2.3 4 5", "1 2 3.4 5", "1 2 3 4 5",
3384 "1.2.3 4 am 5", "1.2.3 4 5 am", "1.2 3 am 4 5",
3385 "1.2 3 4 am 5", "1.2 3 4 5 am", "1 am 2 3.4.5", "1 2 am 3.4.5",
3386 "1 am 2 3 4.5", "1 2 am 3 4.5", "1 2 3 am 4.5", /* 5 elements */
3388 "1.2.3.4.5.6", "1.2.3.4.5 6", "1.2.3.4 5.6", "1.2.3.4 5 6", "1.2.3 4.5.6",
3389 "1.2.3 4.5 6", "1.2.3 4 5.6", "1.2 3.4.5.6", "1.2 3.4.5 6", "1.2 3.4 5.6",
3390 "1.2 3.4 5 6", "1.2 3 4.5.6", "1.2 3 4.5 6", "1.2 3 4 5.6", "1.2 3 4 5 6",
3391 "1 2.3.4.5.6", "1 2.3.4.5 6", "1 2.3.4 5.6", "1 2.3.4 5 6", "1 2.3 4.5.6",
3393 /* following throws an exception on winME */
3394 "1 2.3 4.5 6", "1 2.3 4 5.6", "1 2.3 4 5 6", "1 2 3.4.5.6", "1 2 3.4.5 6",
3396 "1 2 3.4 5.6", "1 2 3.4 5 6", "1 2 3 4.5 6", "1 2 3 4 5.6", "1 2 3 4 5 6",
3398 /* following throws an exception on winME */
3399 "1.2.3 4 am 5 6", "1.2.3 4 5 am 6", "1.2.3 4 5 6 am", "1 am 2 3 4.5.6",
3401 "1 2 am 3 4.5.6", "1 2 3 am 4.5.6"
3404 static void test_VarDateFromStr(void)
3413 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3415 CHECKPTR(VarDateFromStr
);
3416 CHECKPTR(SystemTimeToVariantTime
);
3418 /* Some date formats are relative, so we need to find the current year */
3420 st
.wHour
= st
.wMinute
= st
.wSecond
= st
.wMilliseconds
= 0;
3421 DFS(NULL
); EXPECT_MISMATCH
;
3423 /* Floating point number are not recognised */
3426 EXPECT_DBL(0.0); /* Very old versions accept this string */
3430 /* 1 element - can only be a time, and only if it has am/pm */
3431 DFS("1 am"); EXPECT_DBL(0.04166666666666666);
3433 /* A decimal point is treated as a time separator.
3434 * The following are converted as hours/minutes.
3436 DFS("0.1"); EXPECT_DBL(0.0006944444444444445);
3437 DFS("0.40"); EXPECT_DBL(0.02777777777777778);
3438 DFS("2.5"); EXPECT_DBL(0.08680555555555555);
3439 /* A colon acts as a decimal point */
3440 DFS("0:1"); EXPECT_DBL(0.0006944444444444445);
3441 DFS("0:20"); EXPECT_DBL(0.01388888888888889);
3442 DFS("0:40"); EXPECT_DBL(0.02777777777777778);
3443 DFS("3:5"); EXPECT_DBL(0.1284722222222222);
3444 /* Check the am/pm limits */
3445 DFS("00:00 AM"); EXPECT_DBL(0.0);
3446 DFS("00:00 a"); EXPECT_DBL(0.0);
3447 DFS("12:59 AM"); EXPECT_DBL(0.04097222222222222);
3448 DFS("12:59 A"); EXPECT_DBL(0.04097222222222222);
3449 DFS("00:00 pm"); EXPECT_DBL(0.5);
3450 DFS("00:00 p"); EXPECT_DBL(0.5);
3451 DFS("12:59 pm"); EXPECT_DBL(0.5409722222222222);
3452 DFS("12:59 p"); EXPECT_DBL(0.5409722222222222);
3453 /* AM/PM is ignored if hours > 12 */
3454 DFS("13:00 AM"); EXPECT_DBL(0.5416666666666666);
3455 DFS("13:00 PM"); EXPECT_DBL(0.5416666666666666);
3457 /* Space, dash and slash all indicate a date format. */
3458 /* If both numbers are valid month values => month/day of current year */
3459 DFS("1 2"); MKRELDATE(2,1); EXPECT_DBL(relative
);
3460 DFS("2 1"); MKRELDATE(1,2); EXPECT_DBL(relative
);
3461 /* one number not valid month, is a valid day, other number valid month:
3462 * that number becomes the day.
3464 DFS("14 1"); MKRELDATE(14,1); EXPECT_DBL(relative
);
3465 DFS("1 14"); EXPECT_DBL(relative
);
3466 /* If the numbers can't be day/month, they are assumed to be year/month */
3467 DFS("30 2"); EXPECT_DBL(10990.0);
3468 DFS("2 30"); EXPECT_DBL(10990.0);
3469 DFS("32 49"); EXPECT_MISMATCH
; /* Can't be any format */
3470 DFS("0 49"); EXPECT_MISMATCH
; /* Can't be any format */
3471 /* If a month name is given the other number is the day */
3472 DFS("Jan 2"); MKRELDATE(2,1); EXPECT_DBL(relative
);
3473 DFS("2 Jan"); EXPECT_DBL(relative
);
3474 /* Unless it can't be, in which case it becomes the year */
3475 DFS("Jan 35"); EXPECT_DBL(12785.0);
3476 DFS("35 Jan"); EXPECT_DBL(12785.0);
3477 DFS("Jan-35"); EXPECT_DBL(12785.0);
3478 DFS("35-Jan"); EXPECT_DBL(12785.0);
3479 DFS("Jan/35"); EXPECT_DBL(12785.0);
3480 DFS("35/Jan"); EXPECT_DBL(12785.0);
3482 /* 3 numbers and time separator => h:m:s */
3483 DFS("0.1.0"); EXPECT_DBL(0.0006944444444444445);
3484 DFS("1.5.2"); EXPECT_DBL(0.04516203703703704);
3485 /* 3 numbers => picks date giving preference to lcid format */
3486 DFS("1 2 3"); EXPECT_DBL(37623.0);
3487 DFS("14 2 3"); EXPECT_DBL(41673.0);
3488 DFS("2 14 3"); EXPECT_DBL(37666.0);
3489 DFS("2 3 14"); EXPECT_DBL(41673.0);
3490 DFS("32 2 3"); EXPECT_DBL(11722.0);
3491 DFS("2 3 32"); EXPECT_DBL(11722.0);
3492 DFS("1 2 29"); EXPECT_DBL(47120.0);
3493 /* After 30, two digit dates are expected to be in the 1900's */
3494 DFS("1 2 30"); EXPECT_DBL(10960.0);
3495 DFS("1 2 31"); EXPECT_DBL(11325.0);
3496 DFS("3 am 1 2"); MKRELDATE(2,1); relative
+= 0.125; EXPECT_DBL(relative
);
3497 DFS("1 2 3 am"); EXPECT_DBL(relative
);
3499 /* 4 elements -interpreted as 2 digit date & time */
3500 DFS("1.2 3 4"); MKRELDATE(4,3); relative
+= 0.04305555556; EXPECT_DBL(relative
);
3501 DFS("3 4 1.2"); EXPECT_DBL(relative
);
3502 /* 5 elements - interpreted as 2 & 3 digit date/times */
3503 DFS("1.2.3 4 5"); MKRELDATE(5,4); relative
+= 0.04309027778; EXPECT_DBL(relative
);
3504 DFS("1.2 3 4 5"); EXPECT_DBL(38415.04305555556);
3506 /* following throws an exception on winME */
3507 DFS("1 2 3.4.5"); MKRELDATE(2,1); relative
+= 0.12783564815; EXPECT_DBL(relative
);
3509 DFS("1 2 3 4.5"); EXPECT_DBL(37623.17013888889);
3510 /* 6 elements - interpreted as 3 digit date/times */
3511 DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778);
3512 DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
3514 for (i
= 0; i
< sizeof(BadDateStrings
)/sizeof(char*); i
++)
3516 DFS(BadDateStrings
[i
]); EXPECT_MISMATCH
;
3519 /* Some normal-ish strings */
3520 DFS("2 January, 1970"); EXPECT_DBL(25570.0);
3521 DFS("2 January 1970"); EXPECT_DBL(25570.0);
3522 DFS("2 Jan 1970"); EXPECT_DBL(25570.0);
3523 DFS("2/Jan/1970"); EXPECT_DBL(25570.0);
3524 DFS("2-Jan-1970"); EXPECT_DBL(25570.0);
3525 DFS("1 2 1970"); EXPECT_DBL(25570.0);
3526 DFS("1/2/1970"); EXPECT_DBL(25570.0);
3527 DFS("1-2-1970"); EXPECT_DBL(25570.0);
3528 DFS("13-1-1970"); EXPECT_DBL(25581.0);
3529 DFS("1970-1-13"); EXPECT_DBL(25581.0);
3530 /* Native fails "1999 January 3, 9AM". I consider that a bug in native */
3532 /* test a non-english data string */
3533 DFS("02.01.1970"); EXPECT_MISMATCH
;
3534 DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH
;
3535 lcid
= MAKELCID(MAKELANGID(LANG_GERMAN
,SUBLANG_GERMAN
),SORT_DEFAULT
);
3536 DFS("02.01.1970"); EXPECT_DBL(25570.0);
3537 DFS("02.13.1970"); EXPECT_DBL(25612.0);
3538 DFS("02-13-1970"); EXPECT_DBL(25612.0);
3539 DFS("2020-01-11"); EXPECT_DBL(43841.0);
3540 DFS("2173-10-14"); EXPECT_DBL(100000.0);
3542 DFS("02.01.1970 00:00:00"); EXPECT_DBL(25570.0);
3543 lcid
= MAKELCID(MAKELANGID(LANG_SPANISH
,SUBLANG_SPANISH
),SORT_DEFAULT
);
3544 DFS("02.01.1970"); EXPECT_MISMATCH
;
3545 DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH
;
3548 static void test_VarDateCopy(void)
3550 COPYTEST(77665544.0, VT_DATE
, V_DATE(&vSrc
), V_DATE(&vDst
), V_DATEREF(&vSrc
),
3551 V_DATEREF(&vDst
), "%16.16g");
3554 static const char* wtoascii(LPWSTR lpszIn
)
3556 static char buff
[256];
3557 WideCharToMultiByte(CP_ACP
, 0, lpszIn
, -1, buff
, sizeof(buff
), NULL
, NULL
);
3561 static void test_VarDateChangeTypeEx(void)
3563 static const WCHAR sz25570
[] = {
3564 '1','/','2','/','1','9','7','0','\0' };
3565 static const WCHAR sz25570_2
[] = {
3566 '1','/','2','/','7','0','\0' };
3567 static const WCHAR sz25570Nls
[] = {
3568 '1','/','2','/','1','9','7','0',' ','1','2',':','0','0',':','0','0',' ','A','M','\0' };
3571 VARIANTARG vSrc
, vDst
;
3576 #ifdef HAS_UINT64_TO_FLOAT
3577 INITIAL_TYPETEST(VT_DATE
, V_DATE
, "%g");
3581 V_VT(&vDst
) = VT_EMPTY
;
3582 V_VT(&vSrc
) = VT_DATE
;
3583 V_DATE(&vSrc
) = 25570.0;
3584 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3586 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, VARIANT_NOUSEROVERRIDE
, VT_BSTR
);
3587 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_BSTR
&& V_BSTR(&vDst
) &&
3588 (!lstrcmpW(V_BSTR(&vDst
), sz25570
) || !lstrcmpW(V_BSTR(&vDst
), sz25570_2
)),
3589 "hres=0x%X, type=%d (should be VT_BSTR), *bstr=%s\n",
3590 hres
, V_VT(&vDst
), V_BSTR(&vDst
) ? wtoascii(V_BSTR(&vDst
)) : "?");
3591 VariantClear(&vDst
);
3593 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3596 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, VARIANT_NOUSEROVERRIDE
|VARIANT_USE_NLS
, VT_BSTR
);
3597 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_BSTR
&& V_BSTR(&vDst
) && !lstrcmpW(V_BSTR(&vDst
), sz25570Nls
),
3598 "hres=0x%X, type=%d (should be VT_BSTR), *bstr=%s\n",
3599 hres
, V_VT(&vDst
), V_BSTR(&vDst
) ? wtoascii(V_BSTR(&vDst
)) : "?");
3600 VariantClear(&vDst
);
3609 #define CONV_TYPE CY
3611 #define EXPECTCY(x) \
3612 ok((hres == S_OK && out.int64 == (LONGLONG)(x*CY_MULTIPLIER)), \
3613 "expected " #x "*CY_MULTIPLIER, got (%8x %8x); hres=0x%08x\n", S(out).Hi, S(out).Lo, hres)
3615 #define EXPECTCY64(x,y) \
3616 ok(hres == S_OK && S(out).Hi == (LONG)x && S(out).Lo == y, \
3617 "expected " #x " " #y " (%u,%u), got (%u,%u); hres=0x%08x\n", \
3618 (ULONG)(x), (ULONG)(y), S(out).Hi, S(out).Lo, hres)
3620 static void test_VarCyFromI1(void)
3622 CONVVARS(signed char);
3625 CHECKPTR(VarCyFromI1
);
3626 for (i
= -128; i
< 128; i
++)
3628 CONVERT(VarCyFromI1
,i
); EXPECTCY(i
);
3632 static void test_VarCyFromUI1(void)
3637 CHECKPTR(VarCyFromUI1
);
3638 for (i
= 0; i
< 256; i
++)
3640 CONVERT(VarCyFromUI1
,i
); EXPECTCY(i
);
3644 static void test_VarCyFromI2(void)
3649 CHECKPTR(VarCyFromI2
);
3650 for (i
= -16384; i
< 16384; i
++)
3652 CONVERT(VarCyFromI2
,i
); EXPECTCY(i
);
3656 static void test_VarCyFromUI2(void)
3661 CHECKPTR(VarCyFromUI2
);
3662 for (i
= 0; i
< 32768; i
++)
3664 CONVERT(VarCyFromUI2
,i
); EXPECTCY(i
);
3668 static void test_VarCyFromI4(void)
3672 CHECKPTR(VarCyFromI4
);
3673 CONVERT(VarCyFromI4
, -1); EXPECTCY(-1);
3674 CONVERT(VarCyFromI4
, 0); EXPECTCY(0);
3675 CONVERT(VarCyFromI4
, 1); EXPECTCY(1);
3676 CONVERT(VarCyFromI4
, 0x7fffffff); EXPECTCY64(0x1387, 0xffffd8f0);
3677 CONVERT(VarCyFromI4
, 0x80000000); EXPECTCY64(0xffffec78, 0);
3680 static void test_VarCyFromUI4(void)
3682 CONVVARS(unsigned int);
3684 CHECKPTR(VarCyFromUI4
);
3685 CONVERT(VarCyFromUI4
, 0); EXPECTCY(0);
3686 CONVERT(VarCyFromUI4
, 1); EXPECTCY(1);
3687 CONVERT(VarCyFromUI4
, 0x80000000); EXPECTCY64(5000, 0);
3690 static void test_VarCyFromR4(void)
3694 CHECKPTR(VarCyFromR4
);
3695 CONVERT(VarCyFromR4
, -1.0f
); EXPECTCY(-1);
3696 CONVERT(VarCyFromR4
, 0.0f
); EXPECTCY(0);
3697 CONVERT(VarCyFromR4
, 1.0f
); EXPECTCY(1);
3698 CONVERT(VarCyFromR4
, 1.5f
); EXPECTCY(1.5);
3700 CONVERT(VarCyFromR4
, -1.5f
); EXPECTCY(-1.5);
3701 CONVERT(VarCyFromR4
, -0.6f
); EXPECTCY(-0.6);
3702 CONVERT(VarCyFromR4
, -0.5f
); EXPECTCY(-0.5);
3703 CONVERT(VarCyFromR4
, -0.4f
); EXPECTCY(-0.4);
3704 CONVERT(VarCyFromR4
, 0.4f
); EXPECTCY(0.4);
3705 CONVERT(VarCyFromR4
, 0.5f
); EXPECTCY(0.5);
3706 CONVERT(VarCyFromR4
, 0.6f
); EXPECTCY(0.6);
3707 CONVERT(VarCyFromR4
, 1.5f
); EXPECTCY(1.5);
3708 CONVERT(VarCyFromR4
, 1.00009f
); EXPECTCY(1.0001);
3709 CONVERT(VarCyFromR4
, -1.00001f
); EXPECTCY(-1);
3710 CONVERT(VarCyFromR4
, -1.00005f
); EXPECTCY(-1);
3711 CONVERT(VarCyFromR4
, -0.00009f
); EXPECTCY(-0.0001);
3712 CONVERT(VarCyFromR4
, -0.00005f
); EXPECTCY(0);
3713 CONVERT(VarCyFromR4
, -0.00001f
); EXPECTCY(0);
3714 CONVERT(VarCyFromR4
, 0.00001f
); EXPECTCY(0);
3715 CONVERT(VarCyFromR4
, 0.00005f
); EXPECTCY(0);
3716 CONVERT(VarCyFromR4
, 0.00009f
); EXPECTCY(0.0001);
3717 CONVERT(VarCyFromR4
, -1.00001f
); EXPECTCY(-1);
3718 CONVERT(VarCyFromR4
, -1.00005f
); EXPECTCY(-1);
3719 CONVERT(VarCyFromR4
, -1.00009f
); EXPECTCY(-1.0001);
3722 static void test_VarCyFromR8(void)
3726 CHECKPTR(VarCyFromR8
);
3728 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3729 /* Test our rounding is exactly the same. This fails if the special x86
3730 * code is taken out of VarCyFromR8.
3732 CONVERT(VarCyFromR8
, -461168601842738.7904); EXPECTCY64(0xbfffffff, 0xffffff23);
3735 CONVERT(VarCyFromR8
, -4611686018427388416.1); EXPECT_OVERFLOW
;
3736 CONVERT(VarCyFromR8
, -1.0); EXPECTCY(-1);
3737 CONVERT(VarCyFromR8
, -0.0); EXPECTCY(0);
3738 CONVERT(VarCyFromR8
, 1.0); EXPECTCY(1);
3739 CONVERT(VarCyFromR8
, 4611686018427387648.0); EXPECT_OVERFLOW
;
3742 CONVERT(VarCyFromR8
, -1.5f
); EXPECTCY(-1.5);
3743 CONVERT(VarCyFromR8
, -0.6f
); EXPECTCY(-0.6);
3744 CONVERT(VarCyFromR8
, -0.5f
); EXPECTCY(-0.5);
3745 CONVERT(VarCyFromR8
, -0.4f
); EXPECTCY(-0.4);
3746 CONVERT(VarCyFromR8
, 0.4f
); EXPECTCY(0.4);
3747 CONVERT(VarCyFromR8
, 0.5f
); EXPECTCY(0.5);
3748 CONVERT(VarCyFromR8
, 0.6f
); EXPECTCY(0.6);
3749 CONVERT(VarCyFromR8
, 1.5f
); EXPECTCY(1.5);
3750 CONVERT(VarCyFromR8
, 1.00009f
); EXPECTCY(1.0001);
3751 CONVERT(VarCyFromR8
, -1.00001f
); EXPECTCY(-1);
3752 CONVERT(VarCyFromR8
, -1.00005f
); EXPECTCY(-1);
3753 CONVERT(VarCyFromR8
, -0.00009f
); EXPECTCY(-0.0001);
3754 CONVERT(VarCyFromR8
, -0.00005f
); EXPECTCY(0);
3755 CONVERT(VarCyFromR8
, -0.00001f
); EXPECTCY(0);
3756 CONVERT(VarCyFromR8
, 0.00001f
); EXPECTCY(0);
3757 CONVERT(VarCyFromR8
, 0.00005f
); EXPECTCY(0);
3758 CONVERT(VarCyFromR8
, 0.00009f
); EXPECTCY(0.0001);
3759 CONVERT(VarCyFromR8
, -1.00001f
); EXPECTCY(-1);
3760 CONVERT(VarCyFromR8
, -1.00005f
); EXPECTCY(-1);
3761 CONVERT(VarCyFromR8
, -1.00009f
); EXPECTCY(-1.0001);
3764 static void test_VarCyFromBool(void)
3766 CONVVARS(VARIANT_BOOL
);
3769 CHECKPTR(VarCyFromBool
);
3770 for (i
= -32768; i
< 32768; i
++)
3772 CONVERT(VarCyFromBool
, i
); EXPECTCY(i
);
3776 static void test_VarCyFromI8(void)
3780 CHECKPTR(VarCyFromI8
);
3781 CONVERT_I8(VarCyFromI8
, -214749, 2728163227ul); EXPECT_OVERFLOW
;
3782 CONVERT_I8(VarCyFromI8
, -214749, 2728163228ul); EXPECTCY64(2147483648ul,15808);
3783 CONVERT(VarCyFromI8
, -1); EXPECTCY(-1);
3784 CONVERT(VarCyFromI8
, 0); EXPECTCY(0);
3785 CONVERT(VarCyFromI8
, 1); EXPECTCY(1);
3786 CONVERT_I8(VarCyFromI8
, 214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3787 CONVERT_I8(VarCyFromI8
, 214748, 1566804069); EXPECT_OVERFLOW
;
3790 static void test_VarCyFromUI8(void)
3794 CHECKPTR(VarCyFromUI8
);
3795 CONVERT(VarCyFromUI8
, 0); EXPECTCY(0);
3796 CONVERT(VarCyFromUI8
, 1); EXPECTCY(1);
3797 CONVERT_I8(VarCyFromUI8
, 214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3798 CONVERT_I8(VarCyFromUI8
, 214748, 1566804069); EXPECTCY64(2147483647ul, 4294961488ul);
3799 CONVERT_I8(VarCyFromUI8
, 214748, 1566804070); EXPECT_OVERFLOW
;
3800 CONVERT_I8(VarCyFromUI8
, 214749, 1566804068); EXPECT_OVERFLOW
;
3803 static void test_VarCyFromDec(void)
3807 CHECKPTR(VarCyFromDec
);
3809 CONVERT_BADDEC(VarCyFromDec
);
3811 CONVERT_DEC(VarCyFromDec
,0,0x80,0,1); EXPECTCY(-1);
3812 CONVERT_DEC(VarCyFromDec
,0,0,0,0); EXPECTCY(0);
3813 CONVERT_DEC(VarCyFromDec
,0,0,0,1); EXPECTCY(1);
3815 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3816 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804069); EXPECTCY64(2147483647ul, 4294961488ul);
3817 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804070); EXPECT_OVERFLOW
;
3818 CONVERT_DEC64(VarCyFromDec
,0,0,0,214749, 1566804068); EXPECT_OVERFLOW
;
3820 CONVERT_DEC(VarCyFromDec
,2,0,0,100); EXPECTCY(1);
3821 CONVERT_DEC(VarCyFromDec
,2,0x80,0,100); EXPECTCY(-1);
3822 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1); EXPECTCY(-0.01);
3823 CONVERT_DEC(VarCyFromDec
,2,0,0,1); EXPECTCY(0.01);
3824 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1); EXPECTCY(-0.01);
3825 CONVERT_DEC(VarCyFromDec
,2,0,0,999); EXPECTCY(9.99);
3826 CONVERT_DEC(VarCyFromDec
,2,0x80,0,999); EXPECTCY(-9.99);
3827 CONVERT_DEC(VarCyFromDec
,2,0,0,1500); EXPECTCY(15);
3828 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1500); EXPECTCY(-15);
3831 static void test_VarCyFromDate(void)
3835 CHECKPTR(VarCyFromDate
);
3837 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3838 CONVERT(VarCyFromR8
, -461168601842738.7904); EXPECTCY64(0xbfffffff, 0xffffff23);
3841 CONVERT(VarCyFromDate
, -1.0); EXPECTCY(-1);
3842 CONVERT(VarCyFromDate
, -0.0); EXPECTCY(0);
3843 CONVERT(VarCyFromDate
, 1.0); EXPECTCY(1);
3844 CONVERT(VarCyFromDate
, -4611686018427388416.1); EXPECT_OVERFLOW
;
3845 CONVERT(VarCyFromDate
, 4611686018427387648.0); EXPECT_OVERFLOW
;
3848 CONVERT(VarCyFromDate
, -1.5f
); EXPECTCY(-1.5);
3849 CONVERT(VarCyFromDate
, -0.6f
); EXPECTCY(-0.6);
3850 CONVERT(VarCyFromDate
, -0.5f
); EXPECTCY(-0.5);
3851 CONVERT(VarCyFromDate
, -0.4f
); EXPECTCY(-0.4);
3852 CONVERT(VarCyFromDate
, 0.4f
); EXPECTCY(0.4);
3853 CONVERT(VarCyFromDate
, 0.5f
); EXPECTCY(0.5);
3854 CONVERT(VarCyFromDate
, 0.6f
); EXPECTCY(0.6);
3855 CONVERT(VarCyFromDate
, 1.5f
); EXPECTCY(1.5);
3856 CONVERT(VarCyFromDate
, 1.00009f
); EXPECTCY(1.0001);
3857 CONVERT(VarCyFromDate
, -1.00001f
); EXPECTCY(-1);
3858 CONVERT(VarCyFromDate
, -1.00005f
); EXPECTCY(-1);
3859 CONVERT(VarCyFromDate
, -0.00009f
); EXPECTCY(-0.0001);
3860 CONVERT(VarCyFromDate
, -0.00005f
); EXPECTCY(0);
3861 CONVERT(VarCyFromDate
, -0.00001f
); EXPECTCY(0);
3862 CONVERT(VarCyFromDate
, 0.00001f
); EXPECTCY(0);
3863 CONVERT(VarCyFromDate
, 0.00005f
); EXPECTCY(0);
3864 CONVERT(VarCyFromDate
, 0.00009f
); EXPECTCY(0.0001);
3865 CONVERT(VarCyFromDate
, -1.00001f
); EXPECTCY(-1);
3866 CONVERT(VarCyFromDate
, -1.00005f
); EXPECTCY(-1);
3867 CONVERT(VarCyFromDate
, -1.00009f
); EXPECTCY(-1.0001);
3870 #define MATHVARS1 HRESULT hres; double left = 0.0; CY cyLeft, out
3871 #define MATHVARS2 MATHVARS1; double right = 0.0; CY cyRight
3872 #define MATH1(func, l) left = (double)l; pVarCyFromR8(left, &cyLeft); hres = p##func(cyLeft, &out)
3873 #define MATH2(func, l, r) left = (double)l; right = (double)r; \
3874 pVarCyFromR8(left, &cyLeft); pVarCyFromR8(right, &cyRight); \
3875 hres = p##func(cyLeft, cyRight, &out)
3877 static void test_VarCyAdd(void)
3882 MATH2(VarCyAdd
, 0.5, 0.5); EXPECTCY(1);
3883 MATH2(VarCyAdd
, 0.5, -0.4); EXPECTCY(0.1);
3884 MATH2(VarCyAdd
, 0.5, -0.6); EXPECTCY(-0.1);
3885 MATH2(VarCyAdd
, -0.5, -0.5); EXPECTCY(-1);
3886 MATH2(VarCyAdd
, -922337203685476.0, -922337203685476.0); EXPECT_OVERFLOW
;
3887 MATH2(VarCyAdd
, -922337203685476.0, 922337203685476.0); EXPECTCY(0);
3888 MATH2(VarCyAdd
, 922337203685476.0, -922337203685476.0); EXPECTCY(0);
3889 MATH2(VarCyAdd
, 922337203685476.0, 922337203685476.0); EXPECT_OVERFLOW
;
3892 static void test_VarCyMul(void)
3897 MATH2(VarCyMul
, 534443.0, 0.0); EXPECTCY(0);
3898 MATH2(VarCyMul
, 0.5, 0.5); EXPECTCY(0.25);
3899 MATH2(VarCyMul
, 0.5, -0.4); EXPECTCY(-0.2);
3900 MATH2(VarCyMul
, 0.5, -0.6); EXPECTCY(-0.3);
3901 MATH2(VarCyMul
, -0.5, -0.5); EXPECTCY(0.25);
3902 MATH2(VarCyMul
, 922337203685476.0, 20000); EXPECT_OVERFLOW
;
3905 static void test_VarCySub(void)
3910 MATH2(VarCySub
, 0.5, 0.5); EXPECTCY(0);
3911 MATH2(VarCySub
, 0.5, -0.4); EXPECTCY(0.9);
3912 MATH2(VarCySub
, 0.5, -0.6); EXPECTCY(1.1);
3913 MATH2(VarCySub
, -0.5, -0.5); EXPECTCY(0);
3914 MATH2(VarCySub
, -922337203685476.0, -922337203685476.0); EXPECTCY(0);
3915 MATH2(VarCySub
, -922337203685476.0, 922337203685476.0); EXPECT_OVERFLOW
;
3916 MATH2(VarCySub
, 922337203685476.0, -922337203685476.0); EXPECT_OVERFLOW
;
3917 MATH2(VarCySub
, 922337203685476.0, 922337203685476.0); EXPECTCY(0);
3920 static void test_VarCyAbs(void)
3925 MATH1(VarCyAbs
, 0.5); EXPECTCY(0.5);
3926 MATH1(VarCyAbs
, -0.5); EXPECTCY(0.5);
3927 MATH1(VarCyAbs
, 922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3928 MATH1(VarCyAbs
, -922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3931 static void test_VarCyNeg(void)
3936 MATH1(VarCyNeg
, 0.5); EXPECTCY(-0.5);
3937 MATH1(VarCyNeg
, -0.5); EXPECTCY(0.5);
3938 MATH1(VarCyNeg
, 922337203685476.0); EXPECTCY64(2147483648ul,15808);
3939 MATH1(VarCyNeg
, -922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3942 #define MATHMULI4(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3943 hres = pVarCyMulI4(cyLeft, right, &out)
3945 static void test_VarCyMulI4(void)
3950 CHECKPTR(VarCyMulI4
);
3951 MATHMULI4(534443.0, 0); EXPECTCY(0);
3952 MATHMULI4(0.5, 1); EXPECTCY(0.5);
3953 MATHMULI4(0.5, 2); EXPECTCY(1);
3954 MATHMULI4(922337203685476.0, 1); EXPECTCY64(2147483647ul,4294951488ul);
3955 MATHMULI4(922337203685476.0, 2); EXPECT_OVERFLOW
;
3958 #define MATHMULI8(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3959 hres = pVarCyMulI8(cyLeft, right, &out)
3961 static void test_VarCyMulI8(void)
3966 CHECKPTR(VarCyMulI8
);
3967 MATHMULI8(534443.0, 0); EXPECTCY(0);
3968 MATHMULI8(0.5, 1); EXPECTCY(0.5);
3969 MATHMULI8(0.5, 2); EXPECTCY(1);
3970 MATHMULI8(922337203685476.0, 1); EXPECTCY64(2147483647ul,4294951488ul);
3971 MATHMULI8(922337203685476.0, 2); EXPECT_OVERFLOW
;
3974 #define MATHCMP(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); pVarCyFromR8(right, &cyRight); \
3975 hres = pVarCyCmp(cyLeft, cyRight)
3977 static void test_VarCyCmp(void)
3980 double left
= 0.0, right
= 0.0;
3984 MATHCMP(-1.0, -1.0); EXPECT_EQ
;
3985 MATHCMP(-1.0, 0.0); EXPECT_LT
;
3986 MATHCMP(-1.0, 1.0); EXPECT_LT
;
3987 MATHCMP(-1.0, 2.0); EXPECT_LT
;
3988 MATHCMP(0.0, 1.0); EXPECT_LT
;
3989 MATHCMP(0.0, 0.0); EXPECT_EQ
;
3990 MATHCMP(0.0, -1.0); EXPECT_GT
;
3991 MATHCMP(1.0, -1.0); EXPECT_GT
;
3992 MATHCMP(1.0, 0.0); EXPECT_GT
;
3993 MATHCMP(1.0, 1.0); EXPECT_EQ
;
3994 MATHCMP(1.0, 2.0); EXPECT_LT
;
3997 #define MATHCMPR8(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3998 hres = pVarCyCmpR8(cyLeft, right);
4000 static void test_VarCyCmpR8(void)
4007 CHECKPTR(VarCyCmpR8
);
4008 MATHCMPR8(-1.0, -1.0); EXPECT_EQ
;
4009 MATHCMPR8(-1.0, 0.0); EXPECT_LT
;
4010 MATHCMPR8(-1.0, 1.0); EXPECT_LT
;
4011 MATHCMPR8(-1.0, 2.0); EXPECT_LT
;
4012 MATHCMPR8(0.0, 1.0); EXPECT_LT
;
4013 MATHCMPR8(0.0, 0.0); EXPECT_EQ
;
4014 MATHCMPR8(0.0, -1.0); EXPECT_GT
;
4015 MATHCMPR8(1.0, -1.0); EXPECT_GT
;
4016 MATHCMPR8(1.0, 0.0); EXPECT_GT
;
4017 MATHCMPR8(1.0, 1.0); EXPECT_EQ
;
4018 MATHCMPR8(1.0, 2.0); EXPECT_LT
;
4022 #define MATHRND(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
4023 hres = pVarCyRound(cyLeft, right, &out)
4025 static void test_VarCyRound(void)
4030 CHECKPTR(VarCyRound
);
4031 MATHRND(0.5432, 5); EXPECTCY(0.5432);
4032 MATHRND(0.5432, 4); EXPECTCY(0.5432);
4033 MATHRND(0.5432, 3); EXPECTCY(0.543);
4034 MATHRND(0.5432, 2); EXPECTCY(0.54);
4035 MATHRND(0.5432, 1); EXPECTCY(0.5);
4036 MATHRND(0.5532, 0); EXPECTCY(1);
4037 MATHRND(0.5532, -1); EXPECT_INVALID
;
4039 MATHRND(0.5568, 5); EXPECTCY(0.5568);
4040 MATHRND(0.5568, 4); EXPECTCY(0.5568);
4041 MATHRND(0.5568, 3); EXPECTCY(0.557);
4042 MATHRND(0.5568, 2); EXPECTCY(0.56);
4043 MATHRND(0.5568, 1); EXPECTCY(0.6);
4044 MATHRND(0.5568, 0); EXPECTCY(1);
4045 MATHRND(0.5568, -1); EXPECT_INVALID
;
4047 MATHRND(0.4999, 0); EXPECTCY(0);
4048 MATHRND(0.5000, 0); EXPECTCY(0);
4049 MATHRND(0.5001, 0); EXPECTCY(1);
4050 MATHRND(1.4999, 0); EXPECTCY(1);
4051 MATHRND(1.5000, 0); EXPECTCY(2);
4052 MATHRND(1.5001, 0); EXPECTCY(2);
4055 #define MATHFIX(l) left = l; pVarCyFromR8(left, &cyLeft); \
4056 hres = pVarCyFix(cyLeft, &out)
4058 static void test_VarCyFix(void)
4063 MATHFIX(-1.0001); EXPECTCY(-1);
4064 MATHFIX(-1.4999); EXPECTCY(-1);
4065 MATHFIX(-1.5001); EXPECTCY(-1);
4066 MATHFIX(-1.9999); EXPECTCY(-1);
4067 MATHFIX(-0.0001); EXPECTCY(0);
4068 MATHFIX(-0.4999); EXPECTCY(0);
4069 MATHFIX(-0.5001); EXPECTCY(0);
4070 MATHFIX(-0.9999); EXPECTCY(0);
4071 MATHFIX(0.0001); EXPECTCY(0);
4072 MATHFIX(0.4999); EXPECTCY(0);
4073 MATHFIX(0.5001); EXPECTCY(0);
4074 MATHFIX(0.9999); EXPECTCY(0);
4075 MATHFIX(1.0001); EXPECTCY(1);
4076 MATHFIX(1.4999); EXPECTCY(1);
4077 MATHFIX(1.5001); EXPECTCY(1);
4078 MATHFIX(1.9999); EXPECTCY(1);
4081 #define MATHINT(l) left = l; pVarCyFromR8(left, &cyLeft); \
4082 hres = pVarCyInt(cyLeft, &out)
4084 static void test_VarCyInt(void)
4089 MATHINT(-1.0001); EXPECTCY(-2);
4090 MATHINT(-1.4999); EXPECTCY(-2);
4091 MATHINT(-1.5001); EXPECTCY(-2);
4092 MATHINT(-1.9999); EXPECTCY(-2);
4093 MATHINT(-0.0001); EXPECTCY(-1);
4094 MATHINT(-0.4999); EXPECTCY(-1);
4095 MATHINT(-0.5001); EXPECTCY(-1);
4096 MATHINT(-0.9999); EXPECTCY(-1);
4097 MATHINT(0.0001); EXPECTCY(0);
4098 MATHINT(0.4999); EXPECTCY(0);
4099 MATHINT(0.5001); EXPECTCY(0);
4100 MATHINT(0.9999); EXPECTCY(0);
4101 MATHINT(1.0001); EXPECTCY(1);
4102 MATHINT(1.4999); EXPECTCY(1);
4103 MATHINT(1.5001); EXPECTCY(1);
4104 MATHINT(1.9999); EXPECTCY(1);
4112 #define CONV_TYPE DECIMAL
4114 #define EXPECTDEC(scl, sgn, hi, lo) ok(hres == S_OK && \
4115 S(U(out)).scale == (BYTE)(scl) && S(U(out)).sign == (BYTE)(sgn) && \
4116 out.Hi32 == (ULONG)(hi) && U1(out).Lo64 == (ULONG64)(lo), \
4117 "expected (%d,%d,%d,(%x %x)), got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4118 scl, sgn, hi, (LONG)((LONG64)(lo) >> 32), (LONG)((lo) & 0xffffffff), S(U(out)).scale, \
4119 S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4121 #define EXPECTDEC64(scl, sgn, hi, mid, lo) ok(hres == S_OK && \
4122 S(U(out)).scale == (BYTE)(scl) && S(U(out)).sign == (BYTE)(sgn) && \
4123 out.Hi32 == (ULONG)(hi) && S1(U1(out)).Mid32 == (ULONG)(mid) && \
4124 S1(U1(out)).Lo32 == (ULONG)(lo), \
4125 "expected (%d,%d,%d,(%x %x)), got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4126 scl, sgn, hi, (LONG)(mid), (LONG)(lo), S(U(out)).scale, \
4127 S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4129 /* expect either a positive or negative zero */
4130 #define EXPECTDECZERO() ok(hres == S_OK && S(U(out)).scale == 0 && \
4131 (S(U(out)).sign == 0 || S(U(out)).sign == 0x80) && out.Hi32 == 0 && U1(out).Lo64 == 0, \
4132 "expected zero, got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4133 S(U(out)).scale, S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4135 #define EXPECTDECI if (i < 0) EXPECTDEC(0, 0x80, 0, -i); else EXPECTDEC(0, 0, 0, i)
4137 static void test_VarDecFromI1(void)
4139 CONVVARS(signed char);
4142 CHECKPTR(VarDecFromI1
);
4143 for (i
= -128; i
< 128; i
++)
4145 CONVERT(VarDecFromI1
,i
); EXPECTDECI
;
4149 static void test_VarDecFromI2(void)
4154 CHECKPTR(VarDecFromI2
);
4155 for (i
= -32768; i
< 32768; i
++)
4157 CONVERT(VarDecFromI2
,i
); EXPECTDECI
;
4161 static void test_VarDecFromI4(void)
4166 CHECKPTR(VarDecFromI4
);
4167 for (i
= -32768; i
< 32768; i
++)
4169 CONVERT(VarDecFromI4
,i
); EXPECTDECI
;
4173 static void test_VarDecFromI8(void)
4178 CHECKPTR(VarDecFromI8
);
4179 for (i
= -32768; i
< 32768; i
++)
4181 CONVERT(VarDecFromI8
,i
); EXPECTDECI
;
4185 static void test_VarDecFromUI1(void)
4190 CHECKPTR(VarDecFromUI1
);
4191 for (i
= 0; i
< 256; i
++)
4193 CONVERT(VarDecFromUI1
,i
); EXPECTDECI
;
4197 static void test_VarDecFromUI2(void)
4202 CHECKPTR(VarDecFromUI2
);
4203 for (i
= 0; i
< 65536; i
++)
4205 CONVERT(VarDecFromUI2
,i
); EXPECTDECI
;
4209 static void test_VarDecFromUI4(void)
4214 CHECKPTR(VarDecFromUI4
);
4215 for (i
= 0; i
< 65536; i
++)
4217 CONVERT(VarDecFromUI4
,i
); EXPECTDECI
;
4221 static void test_VarDecFromUI8(void)
4226 CHECKPTR(VarDecFromUI8
);
4227 for (i
= 0; i
< 65536; i
++)
4229 CONVERT(VarDecFromUI8
,i
); EXPECTDECI
;
4233 static void test_VarDecFromBool(void)
4238 CHECKPTR(VarDecFromBool
);
4239 /* Test all possible type values. Note that the result is reduced to 0 or -1 */
4240 for (i
= -32768; i
< 0; i
++)
4242 CONVERT(VarDecFromBool
,i
);
4244 EXPECTDEC(0,0x80,0,1);
4250 static void test_VarDecFromR4(void)
4254 CHECKPTR(VarDecFromR4
);
4256 CONVERT(VarDecFromR4
,-0.6f
); EXPECTDEC(1,0x80,0,6);
4257 CONVERT(VarDecFromR4
,-0.5f
); EXPECTDEC(1,0x80,0,5);
4258 CONVERT(VarDecFromR4
,-0.4f
); EXPECTDEC(1,0x80,0,4);
4259 CONVERT(VarDecFromR4
,0.0f
); EXPECTDEC(0,0,0,0);
4260 CONVERT(VarDecFromR4
,0.4f
); EXPECTDEC(1,0,0,4);
4261 CONVERT(VarDecFromR4
,0.5f
); EXPECTDEC(1,0,0,5);
4262 CONVERT(VarDecFromR4
,0.6f
); EXPECTDEC(1,0,0,6);
4265 static void test_VarDecFromR8(void)
4269 CHECKPTR(VarDecFromR8
);
4271 CONVERT(VarDecFromR8
,-0.6); EXPECTDEC(1,0x80,0,6);
4272 CONVERT(VarDecFromR8
,-0.5); EXPECTDEC(1,0x80,0,5);
4273 CONVERT(VarDecFromR8
,-0.4); EXPECTDEC(1,0x80,0,4);
4274 CONVERT(VarDecFromR8
,0.0); EXPECTDEC(0,0,0,0);
4275 CONVERT(VarDecFromR8
,0.4); EXPECTDEC(1,0,0,4);
4276 CONVERT(VarDecFromR8
,0.5); EXPECTDEC(1,0,0,5);
4277 CONVERT(VarDecFromR8
,0.6); EXPECTDEC(1,0,0,6);
4280 static void test_VarDecFromDate(void)
4284 CHECKPTR(VarDecFromDate
);
4286 CONVERT(VarDecFromDate
,-0.6); EXPECTDEC(1,0x80,0,6);
4287 CONVERT(VarDecFromDate
,-0.5); EXPECTDEC(1,0x80,0,5);
4288 CONVERT(VarDecFromDate
,-0.4); EXPECTDEC(1,0x80,0,4);
4289 CONVERT(VarDecFromDate
,0.0); EXPECTDEC(0,0,0,0);
4290 CONVERT(VarDecFromDate
,0.4); EXPECTDEC(1,0,0,4);
4291 CONVERT(VarDecFromDate
,0.5); EXPECTDEC(1,0,0,5);
4292 CONVERT(VarDecFromDate
,0.6); EXPECTDEC(1,0,0,6);
4295 static void test_VarDecFromStr(void)
4300 CHECKPTR(VarDecFromStr
);
4302 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4304 CONVERT_STR(VarDecFromStr
,NULL
,0); EXPECT_MISMATCH
;
4305 CONVERT_STR(VarDecFromStr
,"-1", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0x80,0,1);
4306 CONVERT_STR(VarDecFromStr
,"0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,0,0);
4307 CONVERT_STR(VarDecFromStr
,"1", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,0,1);
4308 CONVERT_STR(VarDecFromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(1,0,0,5);
4309 CONVERT_STR(VarDecFromStr
,"4294967296", LOCALE_NOUSEROVERRIDE
); EXPECTDEC64(0,0,0,1,0);
4310 CONVERT_STR(VarDecFromStr
,"18446744073709551616", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,1,0);
4311 CONVERT_STR(VarDecFromStr
,"4294967296.0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC64(0,0,0,1,0);
4312 CONVERT_STR(VarDecFromStr
,"18446744073709551616.0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,1,0);
4315 static void test_VarDecFromCy(void)
4319 CHECKPTR(VarDecFromCy
);
4321 CONVERT_CY(VarDecFromCy
, -1); EXPECTDEC(4,0x80,0,10000);
4322 CONVERT_CY(VarDecFromCy
, 0); EXPECTDEC(4,0,0,0);
4323 CONVERT_CY(VarDecFromCy
, 1); EXPECTDEC(4,0,0,10000);
4324 CONVERT_CY(VarDecFromCy
, 0.5); EXPECTDEC(4,0,0,5000);
4328 #define MATHVARS1 HRESULT hres; DECIMAL l, out
4330 #define MATHVARS2 MATHVARS1; DECIMAL r
4332 #define MATH1(func) hres = p##func(&l, &out)
4334 #define MATH2(func) hres = p##func(&l, &r, &out)
4336 #define MATH3(func) hres = p##func(&l, r)
4338 static void test_VarDecAbs(void)
4342 CHECKPTR(VarDecAbs
);
4343 SETDEC(l
,0,0x80,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,1);
4344 SETDEC(l
,0,0,0,0); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,0);
4345 SETDEC(l
,0,0x80,0,0); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,0);
4346 SETDEC(l
,0,0,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,1);
4348 /* Doesn't check for invalid input */
4349 SETDEC(l
,0,0x7f,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0x7f,0,1);
4350 SETDEC(l
,0,0x80,29,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,29,1);
4353 static void test_VarDecNeg(void)
4357 CHECKPTR(VarDecNeg
);
4358 SETDEC(l
,0,0x80,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0,0,1);
4359 SETDEC(l
,0,0,0,0); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,0,0); /* '-0'! */
4360 SETDEC(l
,0,0x80,0,0); MATH1(VarDecNeg
); EXPECTDEC(0,0,0,0);
4361 SETDEC(l
,0,0,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,0,1);
4363 /* Doesn't check for invalid input */
4364 SETDEC(l
,0,0x7f,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0xff,0,1);
4365 SETDEC(l
,0,0x80,29,1); MATH1(VarDecNeg
); EXPECTDEC(0,0,29,1);
4366 SETDEC(l
,0,0,29,1); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,29,1);
4369 static void test_VarDecAdd(void)
4373 CHECKPTR(VarDecAdd
);
4374 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,0);
4375 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4376 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4378 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4379 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,2);
4380 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDECZERO();
4381 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,2); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4383 SETDEC(l
,0,0x80,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4384 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDECZERO();
4385 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0,0,2); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4386 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,2);
4387 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4389 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,0xfffffffe);
4390 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,(ULONG64
)1 << 32);
4391 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,(ULONG64
)1 << 32);
4393 SETDEC64(l
,0,0,0,0xffffffff,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC64(0,0,0,0xffffffff,1);
4394 SETDEC64(l
,0,0,0,0xffffffff,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4395 EXPECTDEC64(0,0,0,0xfffffffe,0xffffffff);
4397 SETDEC64(l
,0,0,0,0xffffffff,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,1,0);
4398 SETDEC64(l
,0,0,0,0xffffffff,0xffffffff); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4399 EXPECTDEC64(0,0,0,0xffffffff,0xfffffffe);
4401 SETDEC(l
,0,0,0xffffffff,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0xffffffff,1);
4402 SETDEC(l
,0,0,0xffffffff,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4403 EXPECTDEC64(0,0,0xfffffffe,0xffffffff,0xffffffff);
4405 SETDEC64(l
,0,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4406 EXPECTDEC64(0,0,0xffffffff,0xffffffff,0xfffffffe);
4407 SETDEC64(l
,0,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
);
4408 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4409 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4411 SETDEC64(l
,1,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,1,0,0,1); MATH2(VarDecAdd
);
4412 todo_wine
EXPECTDEC64(0,0,0x19999999,0x99999999,0x9999999A);
4414 SETDEC64(l
,0,0,0xe22ea493,0xb30310a7,0x70000000);SETDEC64(r
,0,0,0xe22ea493,0xb30310a7,0x70000000); MATH2(VarDecAdd
);
4415 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4416 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4418 SETDEC64(l
,1,0,0xe22ea493,0xb30310a7,0x70000000);SETDEC64(r
,1,0,0xe22ea493,0xb30310a7,0x70000000); MATH2(VarDecAdd
);
4419 todo_wine
EXPECTDEC64(0,0,0x2d3c8750,0xbd670354,0xb0000000);
4421 SETDEC(l
,3,128,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4422 MATH2(VarDecAdd
); todo_wine
EXPECTDEC64(0,0,-1,0xFFFFFFFF,0xFFFFFF84);
4424 SETDEC(l
,3,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4425 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4426 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4428 SETDEC(l
,4,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4429 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4430 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4432 SETDEC(l
,5,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4433 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4434 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4436 SETDEC(l
,6,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4437 MATH2(VarDecAdd
); todo_wine
EXPECTDEC64(0,0,-1,0xFFFFFFFF,0xFFFFFFFF);
4439 SETDEC(l
,3,128,0,123456); SETDEC64(r
,0,0,0x19999999,0x99999999,0x99999999);
4440 MATH2(VarDecAdd
); todo_wine
EXPECTDEC64(1,0,-1,0xFFFFFFFF,0xFFFFFB27);
4442 SETDEC(l
,3,128,0,123567); SETDEC64(r
,0,0,0x19999999,0x99999999,0x99999999);
4443 MATH2(VarDecAdd
); todo_wine
EXPECTDEC64(1,0,-1,0xFFFFFFFF,0xFFFFFB26);
4445 /* Promotes to the highest scale, so here the results are in the scale of 2 */
4446 SETDEC(l
,2,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(2,0,0,0);
4447 SETDEC(l
,2,0,0,100); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(2,0,0,200);
4450 static void test_VarDecSub(void)
4454 CHECKPTR(VarDecSub
);
4455 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecSub
); EXPECTDECZERO();
4456 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecSub
); EXPECTDEC(0,0x80,0,1);
4457 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecSub
); EXPECTDECZERO();
4458 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecSub
); EXPECTDEC(0,0,0,2);
4461 static void test_VarDecMul(void)
4465 CHECKPTR(VarDecMul
);
4466 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4467 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4468 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4469 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0,1);
4470 SETDEC(l
,0,0,0,45000);SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0,0,90000);
4471 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0,0,45000); MATH2(VarDecMul
); EXPECTDEC(0,0,0,90000);
4473 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0x80,0,4);
4474 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0x80,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0x80,0,4);
4475 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0x80,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0,0,4);
4477 SETDEC(l
,4,0,0,2); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(4,0,0,4);
4478 SETDEC(l
,0,0,0,2); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(3,0,0,4);
4479 SETDEC(l
,4,0,0,2); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(7,0,0,4);
4480 /* this last one shows that native oleaut32 does *not* gratuitously seize opportunities
4481 to reduce the scale if possible - the canonical result for the expected value is (6,0,0,1)
4483 SETDEC(l
,4,0,0,5); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(7,0,0,10);
4485 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC64(0,0,1,0xFFFFFFFF,0xFFFFFFFE);
4486 SETDEC(l
,0,0,0,2); SETDEC64(r
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecMul
); EXPECTDEC64(0,0,1,0xFFFFFFFF,0xFFFFFFFE);
4487 SETDEC(l
,0,0,1,1); SETDEC(r
,0,0,0,0x80000000); MATH2(VarDecMul
); EXPECTDEC(0,0,0x80000000,0x80000000);
4488 SETDEC(l
,0,0,0,0x80000000); SETDEC(r
,0,0,1,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0x80000000,0x80000000);
4490 /* near-overflow, used as a reference */
4491 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC(r
,0,0,0,2000000000); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4492 /* actual overflow - right operand is 10 times the previous value */
4493 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,4,0xA817C800); MATH2(VarDecMul
);
4494 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4495 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4496 /* here, native oleaut32 has an opportunity to avert the overflow, by reducing the scale of the result */
4497 SETDEC64(l
,1,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,4,0xA817C800); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4499 /* near-overflow, used as a reference */
4500 SETDEC64(l
,0,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC(r
,0,0,0,1000000000); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4501 /* actual overflow - right operand is 10 times the previous value */
4502 SETDEC64(l
,0,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC64(r
,0,0,0,2,0x540BE400); MATH2(VarDecMul
);
4503 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4504 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4505 /* here, native oleaut32 has an opportunity to avert the overflow, by reducing the scale of the result */
4506 SETDEC64(l
,1,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC64(r
,0,0,0,2,0x540BE400); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4508 /* this one shows that native oleaut32 is willing to lose significant digits in order to avert an overflow */
4509 SETDEC64(l
,2,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,9,0x502F9001); MATH2(VarDecMul
);EXPECTDEC64(1,0,0xee6b2800,0x19999998,0xab2e719a);
4512 static void test_VarDecDiv(void)
4516 CHECKPTR(VarDecDiv
);
4517 /* identity divisions */
4518 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,0);
4519 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,1);
4520 SETDEC(l
,1,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(1,0,0,1);
4522 /* exact divisions */
4523 SETDEC(l
,0,0,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,5);
4524 SETDEC(l
,1,0,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(1,0,0,5);
4525 SETDEC(l
,0,0,0,45); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,50);
4526 SETDEC(l
,1,0,0,45); SETDEC(r
,2,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,50);
4527 /* these last three results suggest that native oleaut32 scales both operands down to zero
4528 before the division, but does not always try to scale the result, even if it is possible -
4529 analogous to multiplication behavior.
4531 SETDEC(l
,1,0,0,45); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,5);
4532 SETDEC(l
,2,0,0,450); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
);
4533 if (S(U(out
)).scale
== 1) EXPECTDEC(1,0,0,50);
4534 else EXPECTDEC(0,0,0,5);
4536 /* inexact divisions */
4537 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4538 SETDEC(l
,1,0,0,1); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,18070036,0x35458014,0x4d555555);
4539 SETDEC(l
,0,0,0,1); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,1807003620,0xcf2607ee,0x35555555);
4540 SETDEC(l
,1,0,0,1); SETDEC(r
,2,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,1807003620,0xcf2607ee,0x35555555);
4541 SETDEC(l
,1,0,0,1); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4542 SETDEC(l
,2,0,0,10); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4544 /* this one shows that native oleaut32 rounds up the result */
4545 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,361400724,0x296e0196,0x0aaaaaab);
4548 SETDEC(l
,0,0x80,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0x80,0,5);
4549 SETDEC(l
,0,0,0,45); SETDEC(r
,0,0x80,0,9); MATH2(VarDecDiv
);EXPECTDEC(0,0x80,0,5);
4550 SETDEC(l
,0,0x80,0,45); SETDEC(r
,0,0x80,0,9); MATH2(VarDecDiv
);EXPECTDEC(0,0,0,5);
4553 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecDiv
);/* indeterminate */
4554 ok(hres
== DISP_E_DIVBYZERO
,"Expected division-by-zero, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4555 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4556 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecDiv
);/* division by zero */
4557 ok(hres
== DISP_E_DIVBYZERO
,"Expected division-by-zero, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4558 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4562 static void test_VarDecCmp(void)
4566 CHECKPTR(VarDecCmp
);
4568 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4569 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4570 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4572 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4573 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4574 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4576 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4577 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4578 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4580 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4581 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4582 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4584 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4585 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4586 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4588 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4589 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4590 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4592 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4593 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4594 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4596 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4597 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4598 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4600 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4601 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4602 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4604 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4605 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4606 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4608 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4609 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4610 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4612 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4613 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4614 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4617 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4618 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4619 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4621 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4622 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4623 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4625 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4626 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4627 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4629 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4630 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4631 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4633 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4634 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4635 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4637 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4638 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4639 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4641 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4642 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4643 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4645 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4646 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4647 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4649 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4650 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4651 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4653 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4654 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4655 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4657 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4658 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4659 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4661 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4662 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4663 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4665 SETDEC(l
,3,0,0,123456); SETDEC64(out
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4666 MATH1(VarDecCmp
); todo_wine EXPECT_LT
;
4669 static void test_VarDecCmpR8(void)
4675 CHECKPTR(VarDecCmpR8
);
4677 SETDEC(l
,0,0,0,1); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_GT
;
4678 SETDEC(l
,0,0,0,1); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4679 SETDEC(l
,0,0,0,1); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4681 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_LT
;
4682 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4683 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4685 SETDEC(l
,0,0,0,0); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_EQ
;
4686 SETDEC(l
,0,0,0,0); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4687 SETDEC(l
,0,0,0,0); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4689 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_EQ
;
4690 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4691 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4693 SETDEC(l
,0,0,0,1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4694 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4695 SETDEC(l
,0,0,-1,-1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_GT
;
4696 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4699 #define CLEAR(x) memset(&(x), 0xBB, sizeof(x))
4701 static void test_VarDecRound(void)
4706 CHECKPTR(VarDecRound
);
4708 CLEAR(out
); SETDEC(l
, 0, 0, 0, 1); hres
= pVarDecRound(&l
, 3, &out
); EXPECTDEC(0, 0, 0, 1);
4710 CLEAR(out
); SETDEC(l
, 0, 0, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, 0, 0, 1);
4711 CLEAR(out
); SETDEC(l
, 1, 0, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, 0, 0, 0);
4712 CLEAR(out
); SETDEC(l
, 1, 0, 0, 1); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 1);
4713 CLEAR(out
); SETDEC(l
, 2, 0, 0, 11); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 1);
4714 CLEAR(out
); SETDEC(l
, 2, 0, 0, 15); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 2);
4715 CLEAR(out
); SETDEC(l
, 6, 0, 0, 550001); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 6);
4717 CLEAR(out
); SETDEC(l
, 0, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, DECIMAL_NEG
, 0, 1);
4718 CLEAR(out
); SETDEC(l
, 1, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, DECIMAL_NEG
, 0, 0);
4719 CLEAR(out
); SETDEC(l
, 1, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 1);
4720 CLEAR(out
); SETDEC(l
, 2, DECIMAL_NEG
, 0, 11); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 1);
4721 CLEAR(out
); SETDEC(l
, 2, DECIMAL_NEG
, 0, 15); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 2);
4722 CLEAR(out
); SETDEC(l
, 6, DECIMAL_NEG
, 0, 550001); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 6);
4724 CLEAR(out
); SETDEC64(l
, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, 0, 0xffffffff, 0xffffffff, 0xffffffff);
4725 CLEAR(out
); SETDEC64(l
, 28, 0, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, 0, 0, 0, 8);
4726 CLEAR(out
); SETDEC64(l
, 0, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff);
4727 CLEAR(out
); SETDEC64(l
, 28, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, DECIMAL_NEG
, 0, 0, 8);
4729 CLEAR(out
); SETDEC(l
, 2, 0, 0, 0); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 0);
4737 #define CONV_TYPE VARIANT_BOOL
4739 #define EXPECTRES(res, x) _EXPECTRES(res, x, "%d")
4741 #define CONVERTRANGE(func,start,end) for (i = start; i < end; i++) { \
4742 CONVERT(func, i); if (i) { EXPECT(VARIANT_TRUE); } else { EXPECT(VARIANT_FALSE); } }
4744 static void test_VarBoolFromI1(void)
4746 CONVVARS(signed char);
4749 CHECKPTR(VarBoolFromI1
);
4750 CONVERTRANGE(VarBoolFromI1
, -128, 128);
4753 static void test_VarBoolFromUI1(void)
4758 CHECKPTR(VarBoolFromUI1
);
4759 CONVERTRANGE(VarBoolFromUI1
, 0, 256);
4762 static void test_VarBoolFromI2(void)
4767 CHECKPTR(VarBoolFromI2
);
4768 CONVERTRANGE(VarBoolFromI2
, -32768, 32768);
4771 static void test_VarBoolFromUI2(void)
4776 CHECKPTR(VarBoolFromUI2
);
4777 CONVERTRANGE(VarBoolFromUI2
, 0, 65536);
4780 static void test_VarBoolFromI4(void)
4784 CHECKPTR(VarBoolFromI4
);
4785 CONVERT(VarBoolFromI4
, 0x80000000); EXPECT(VARIANT_TRUE
);
4786 CONVERT(VarBoolFromI4
, -1); EXPECT(VARIANT_TRUE
);
4787 CONVERT(VarBoolFromI4
, 0); EXPECT(VARIANT_FALSE
);
4788 CONVERT(VarBoolFromI4
, 1); EXPECT(VARIANT_TRUE
);
4789 CONVERT(VarBoolFromI4
, 0x7fffffff); EXPECT(VARIANT_TRUE
);
4792 static void test_VarBoolFromUI4(void)
4796 CHECKPTR(VarBoolFromUI4
);
4797 CONVERT(VarBoolFromI4
, 0); EXPECT(VARIANT_FALSE
);
4798 CONVERT(VarBoolFromI4
, 1); EXPECT(VARIANT_TRUE
);
4799 CONVERT(VarBoolFromI4
, 0x80000000); EXPECT(VARIANT_TRUE
);
4802 static void test_VarBoolFromR4(void)
4806 CHECKPTR(VarBoolFromR4
);
4807 CONVERT(VarBoolFromR4
, -1.0f
); EXPECT(VARIANT_TRUE
);
4808 CONVERT(VarBoolFromR4
, 0.0f
); EXPECT(VARIANT_FALSE
);
4809 CONVERT(VarBoolFromR4
, 1.0f
); EXPECT(VARIANT_TRUE
);
4810 CONVERT(VarBoolFromR4
, 1.5f
); EXPECT(VARIANT_TRUE
);
4813 CONVERT(VarBoolFromR4
, -1.5f
); EXPECT(VARIANT_TRUE
);
4814 CONVERT(VarBoolFromR4
, -0.6f
); EXPECT(VARIANT_TRUE
);
4815 CONVERT(VarBoolFromR4
, -0.5f
); EXPECT(VARIANT_TRUE
);
4816 CONVERT(VarBoolFromR4
, -0.4f
); EXPECT(VARIANT_TRUE
);
4817 CONVERT(VarBoolFromR4
, 0.4f
); EXPECT(VARIANT_TRUE
);
4818 CONVERT(VarBoolFromR4
, 0.5f
); EXPECT(VARIANT_TRUE
);
4819 CONVERT(VarBoolFromR4
, 0.6f
); EXPECT(VARIANT_TRUE
);
4820 CONVERT(VarBoolFromR4
, 1.5f
); EXPECT(VARIANT_TRUE
);
4823 static void test_VarBoolFromR8(void)
4827 /* Hopefully we made the point with R4 above that rounding is
4828 * irrelevant, so we'll skip that for R8 and Date
4830 CHECKPTR(VarBoolFromR8
);
4831 CONVERT(VarBoolFromR8
, -1.0); EXPECT(VARIANT_TRUE
);
4832 CONVERT(VarBoolFromR8
, -0.0); EXPECT(VARIANT_FALSE
);
4833 CONVERT(VarBoolFromR8
, 1.0); EXPECT(VARIANT_TRUE
);
4836 static void test_VarBoolFromCy(void)
4840 CHECKPTR(VarBoolFromCy
);
4841 CONVERT_CY(VarBoolFromCy
, -32769); EXPECT(VARIANT_TRUE
);
4842 CONVERT_CY(VarBoolFromCy
, -32768); EXPECT(VARIANT_TRUE
);
4843 CONVERT_CY(VarBoolFromCy
, -1); EXPECT(VARIANT_TRUE
);
4844 CONVERT_CY(VarBoolFromCy
, 0); EXPECT(VARIANT_FALSE
);
4845 CONVERT_CY(VarBoolFromCy
, 1); EXPECT(VARIANT_TRUE
);
4846 CONVERT_CY(VarBoolFromCy
, 32767); EXPECT(VARIANT_TRUE
);
4847 CONVERT_CY(VarBoolFromCy
, 32768); EXPECT(VARIANT_TRUE
);
4850 static void test_VarBoolFromI8(void)
4854 CHECKPTR(VarBoolFromI8
);
4855 CONVERT(VarBoolFromI8
, -1); EXPECT(VARIANT_TRUE
);
4856 CONVERT(VarBoolFromI8
, 0); EXPECT(VARIANT_FALSE
);
4857 CONVERT(VarBoolFromI8
, 1); EXPECT(VARIANT_TRUE
);
4860 static void test_VarBoolFromUI8(void)
4864 CHECKPTR(VarBoolFromUI8
);
4865 CONVERT(VarBoolFromUI8
, 0); EXPECT(VARIANT_FALSE
);
4866 CONVERT(VarBoolFromUI8
, 1); EXPECT(VARIANT_TRUE
);
4869 static void test_VarBoolFromDec(void)
4873 CHECKPTR(VarBoolFromDec
);
4874 CONVERT_BADDEC(VarBoolFromDec
);
4876 CONVERT_DEC(VarBoolFromDec
,29,0,0,0); EXPECT_INVALID
;
4877 CONVERT_DEC(VarBoolFromDec
,0,0x1,0,0); EXPECT_INVALID
;
4878 CONVERT_DEC(VarBoolFromDec
,0,0x40,0,0); EXPECT_INVALID
;
4879 CONVERT_DEC(VarBoolFromDec
,0,0x7f,0,0); EXPECT_INVALID
;
4881 CONVERT_DEC(VarBoolFromDec
,0,0x80,0,1); EXPECT(VARIANT_TRUE
);
4882 CONVERT_DEC(VarBoolFromDec
,0,0,0,0); EXPECT(VARIANT_FALSE
);
4883 CONVERT_DEC(VarBoolFromDec
,0,0,0,1); EXPECT(VARIANT_TRUE
);
4884 CONVERT_DEC(VarBoolFromDec
,0,0,1,0); EXPECT(VARIANT_TRUE
);
4886 CONVERT_DEC(VarBoolFromDec
,2,0,0,CY_MULTIPLIER
); EXPECT(VARIANT_TRUE
);
4887 CONVERT_DEC(VarBoolFromDec
,2,0x80,0,CY_MULTIPLIER
); EXPECT(VARIANT_TRUE
);
4890 static void test_VarBoolFromDate(void)
4894 CHECKPTR(VarBoolFromDate
);
4895 CONVERT(VarBoolFromDate
, -1.0); EXPECT(VARIANT_TRUE
);
4896 CONVERT(VarBoolFromDate
, -0.0); EXPECT(VARIANT_FALSE
);
4897 CONVERT(VarBoolFromDate
, 1.0); EXPECT(VARIANT_TRUE
);
4900 static void test_VarBoolFromStr(void)
4905 CHECKPTR(VarBoolFromStr
);
4907 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4909 CONVERT_STR(VarBoolFromStr
,NULL
,0);
4910 if (hres
!= E_INVALIDARG
)
4913 /* #FALSE# and #TRUE# Are always accepted */
4914 CONVERT_STR(VarBoolFromStr
,"#FALSE#",0); EXPECT(VARIANT_FALSE
);
4915 CONVERT_STR(VarBoolFromStr
,"#TRUE#",0); EXPECT(VARIANT_TRUE
);
4917 /* Match of #FALSE# and #TRUE# is case sensitive */
4918 CONVERT_STR(VarBoolFromStr
,"#False#",0); EXPECT_MISMATCH
;
4919 /* But match against English is not */
4920 CONVERT_STR(VarBoolFromStr
,"false",0); EXPECT(VARIANT_FALSE
);
4921 CONVERT_STR(VarBoolFromStr
,"False",0); EXPECT(VARIANT_FALSE
);
4922 /* On/Off and yes/no are not acceptable inputs, with any flags set */
4923 CONVERT_STR(VarBoolFromStr
,"On",0xffffffff); EXPECT_MISMATCH
;
4924 CONVERT_STR(VarBoolFromStr
,"Yes",0xffffffff); EXPECT_MISMATCH
;
4926 /* Change the LCID. This doesn't make any difference for text,unless we ask
4927 * to check local boolean text with the VARIANT_LOCALBOOL flag. */
4928 in
= MAKELCID(MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
4930 /* #FALSE# and #TRUE# are accepted in all locales */
4931 CONVERT_STR(VarBoolFromStr
,"#FALSE#",0); EXPECT(VARIANT_FALSE
);
4932 CONVERT_STR(VarBoolFromStr
,"#TRUE#",0); EXPECT(VARIANT_TRUE
);
4933 CONVERT_STR(VarBoolFromStr
,"#FALSE#",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4934 CONVERT_STR(VarBoolFromStr
,"#TRUE#",VARIANT_LOCALBOOL
); EXPECT(VARIANT_TRUE
);
4936 /* English is accepted regardless of the locale */
4937 CONVERT_STR(VarBoolFromStr
,"false",0); EXPECT(VARIANT_FALSE
);
4938 /* And is still not case sensitive */
4939 CONVERT_STR(VarBoolFromStr
,"False",0); EXPECT(VARIANT_FALSE
);
4943 /* French is rejected without VARIANT_LOCALBOOL */
4944 CONVERT_STR(VarBoolFromStr
,"faux",0); EXPECT_MISMATCH
;
4945 /* But accepted if this flag is given */
4946 CONVERT_STR(VarBoolFromStr
,"faux",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4947 /* Regardless of case - from this we assume locale text comparisons ignore case */
4948 CONVERT_STR(VarBoolFromStr
,"Faux",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4950 /* Changing the locale prevents the localised text from being compared -
4951 * this demonstrates that only the indicated LCID and English are searched */
4952 in
= MAKELCID(MAKELANGID(LANG_POLISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
4953 CONVERT_STR(VarBoolFromStr
,"faux",VARIANT_LOCALBOOL
); EXPECT_MISMATCH
;
4956 /* Numeric strings are read as 0 or non-0 */
4957 CONVERT_STR(VarBoolFromStr
,"0",0); EXPECT(VARIANT_FALSE
);
4958 CONVERT_STR(VarBoolFromStr
,"-1",0); EXPECT(VARIANT_TRUE
);
4959 CONVERT_STR(VarBoolFromStr
,"+1",0); EXPECT(VARIANT_TRUE
);
4963 /* Numeric strings are read as floating point numbers. The line below fails
4964 * because '.' is not a valid decimal separator for Polish numbers */
4965 CONVERT_STR(VarBoolFromStr
,"0.1",LOCALE_NOUSEROVERRIDE
); EXPECT_MISMATCH
;
4968 /* Changing the lcid back to US English reads the r8 correctly */
4969 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4970 CONVERT_STR(VarBoolFromStr
,"0.1",LOCALE_NOUSEROVERRIDE
); EXPECT(VARIANT_TRUE
);
4973 static void test_VarBoolCopy(void)
4975 COPYTEST(1, VT_BOOL
, V_BOOL(&vSrc
), V_BOOL(&vDst
), V_BOOLREF(&vSrc
), V_BOOLREF(&vDst
), "%d");
4978 #define BOOL_STR(flags, str) hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, flags, VT_BSTR); \
4979 ok(hres == S_OK && V_VT(&vDst) == VT_BSTR && \
4980 V_BSTR(&vDst) && !memcmp(V_BSTR(&vDst), str, sizeof(str)), \
4981 "hres=0x%X, type=%d (should be VT_BSTR), *bstr='%c'\n", \
4982 hres, V_VT(&vDst), V_BSTR(&vDst) ? *V_BSTR(&vDst) : '?'); \
4985 static void test_VarBoolChangeTypeEx(void)
4987 static const WCHAR szTrue
[] = { 'T','r','u','e','\0' };
4988 static const WCHAR szFalse
[] = { 'F','a','l','s','e','\0' };
4989 static const WCHAR szFaux
[] = { 'F','a','u','x','\0' };
4992 VARIANTARG vSrc
, vDst
;
4997 INITIAL_TYPETEST(VT_BOOL
, V_BOOL
, "%d");
5000 /* The common tests convert to a number. Try the different flags */
5001 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5003 V_VT(&vSrc
) = VT_BOOL
;
5006 BOOL_STR(VARIANT_ALPHABOOL
, szTrue
);
5008 BOOL_STR(VARIANT_ALPHABOOL
, szFalse
);
5012 lcid
= MAKELCID(MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5014 /* VARIANT_ALPHABOOL is always English */
5015 BOOL_STR(VARIANT_ALPHABOOL
, szFalse
);
5016 /* VARIANT_LOCALBOOL uses the localised text */
5017 BOOL_STR(VARIANT_LOCALBOOL
, szFaux
);
5018 /* Both flags together acts as VARIANT_LOCALBOOL */
5019 BOOL_STR(VARIANT_ALPHABOOL
|VARIANT_LOCALBOOL
, szFaux
);
5027 static void test_VarBstrFromR4(void)
5029 static const WCHAR szNative
[] = { '6','5','4','3','2','2','.','3','\0' };
5030 static const WCHAR szZero
[] = {'0', '\0'};
5031 static const WCHAR szOneHalf_English
[] = { '0','.','5','\0' }; /* uses period */
5032 static const WCHAR szOneHalf_Spanish
[] = { '0',',','5','\0' }; /* uses comma */
5040 CHECKPTR(VarBstrFromR4
);
5042 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5043 lcid_spanish
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH
), SORT_DEFAULT
);
5045 hres
= pVarBstrFromR4(f
, lcid
, 0, &bstr
);
5046 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5050 /* MSDN states that rounding of R4/R8 is dependent on the underlying
5051 * bit pattern of the number and so is architecture dependent. In this
5052 * case Wine returns .2 (which is more correct) and Native returns .3
5054 ok(memcmp(bstr
, szNative
, sizeof(szNative
)) == 0, "string different\n");
5056 SysFreeString(bstr
);
5060 hres
= pVarBstrFromR4(f
, lcid
, 0, &bstr
);
5061 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5065 ok(memcmp(bstr
+ 1, szZero
, sizeof(szZero
)) == 0, "negative zero (got %s)\n", wtoascii(bstr
));
5067 ok(memcmp(bstr
, szZero
, sizeof(szZero
)) == 0, "negative zero (got %s)\n", wtoascii(bstr
));
5068 SysFreeString(bstr
);
5071 /* The following tests that lcid is used for decimal separator even without LOCALE_USE_NLS */
5073 hres
= pVarBstrFromR4(f
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5074 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5077 ok(memcmp(bstr
, szOneHalf_English
, sizeof(szOneHalf_English
)) == 0, "English locale failed (got %s)\n", wtoascii(bstr
));
5078 SysFreeString(bstr
);
5081 hres
= pVarBstrFromR4(f
, lcid_spanish
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5082 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5085 ok(memcmp(bstr
, szOneHalf_Spanish
, sizeof(szOneHalf_Spanish
)) == 0, "Spanish locale failed (got %s)\n", wtoascii(bstr
));
5086 SysFreeString(bstr
);
5090 static void _BSTR_DATE(DATE dt
, const char *str
, int line
)
5092 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5097 hres
= pVarBstrFromDate(dt
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5100 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5101 SysFreeString(bstr
);
5105 ok_(__FILE__
, line
)(hres
== S_OK
&& !strcmp(str
, buff
),
5106 "Expected '%s', got '%s', hres = 0x%08x\n", str
, buff
, hres
);
5109 static void test_VarBstrFromDate(void)
5111 #define BSTR_DATE(dt,str) _BSTR_DATE(dt,str,__LINE__)
5113 CHECKPTR(VarBstrFromDate
);
5115 BSTR_DATE(0.0, "12:00:00 AM");
5116 BSTR_DATE(3.34, "1/2/1900 8:09:36 AM");
5117 BSTR_DATE(3339.34, "2/20/1909 8:09:36 AM");
5118 BSTR_DATE(365.00, "12/30/1900");
5119 BSTR_DATE(365.25, "12/30/1900 6:00:00 AM");
5120 BSTR_DATE(1461.0, "12/31/1903");
5121 BSTR_DATE(1461.5, "12/31/1903 12:00:00 PM");
5122 BSTR_DATE(-49192.24, "4/24/1765 5:45:36 AM");
5123 BSTR_DATE(-657434.0, "1/1/100");
5124 BSTR_DATE(2958465.0, "12/31/9999");
5129 static void _BSTR_CY(LONG a
, LONG b
, const char *str
, LCID lcid
, int line
)
5138 hr
= pVarBstrFromCy(l
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5139 ok(hr
== S_OK
, "got hr 0x%08x\n", hr
);
5143 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5144 SysFreeString(bstr
);
5151 ok_(__FILE__
, line
)(!strcmp(str
, buff
), "Expected '%s', got '%s'\n", str
, buff
);
5155 static void test_VarBstrFromCy(void)
5157 #define BSTR_CY(a, b, str, lcid) _BSTR_CY(a, b, str, lcid, __LINE__)
5161 CHECKPTR(VarBstrFromCy
);
5163 en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5164 sp
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5166 BSTR_CY(0, 0, "0", en_us
);
5167 BSTR_CY(0, 10000, "1", en_us
);
5168 BSTR_CY(0, 15000, "1.5", en_us
);
5169 BSTR_CY(0xffffffff, ((15000)^0xffffffff)+1, "-1.5", en_us
);
5170 /* (1 << 32) - 1 / 1000 */
5171 BSTR_CY(0, 0xffffffff, "429496.7295", en_us
);
5172 /* (1 << 32) / 1000 */
5173 BSTR_CY(1, 0, "429496.7296", en_us
);
5174 /* ((1 << 63) - 1)/10000 */
5175 BSTR_CY(0x7fffffff, 0xffffffff, "922337203685477.5807", en_us
);
5176 BSTR_CY(0, 9, "0.0009", en_us
);
5177 BSTR_CY(0, 9, "0,0009", sp
);
5182 static void _BSTR_DEC(BYTE scale
, BYTE sign
, ULONG hi
, ULONG mid
, ULONGLONG lo
, const char *str
,
5183 LCID lcid
, int line
)
5190 SETDEC64(dec
, scale
, sign
, hi
, mid
, lo
);
5191 hr
= pVarBstrFromDec(&dec
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5192 ok_(__FILE__
, line
)(hr
== S_OK
, "got hr 0x%08x\n", hr
);
5196 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5197 SysFreeString(bstr
);
5204 ok_(__FILE__
, line
)(!strcmp(str
, buff
), "Expected '%s', got '%s'\n", str
, buff
);
5208 static void test_VarBstrFromDec(void)
5210 #define BSTR_DEC(scale, sign, hi, lo, str, lcid) _BSTR_DEC(scale, sign, hi, 0, lo, str, lcid, __LINE__)
5211 #define BSTR_DEC64(scale, sign, hi, mid, lo, str, lcid) _BSTR_DEC(scale, sign, hi, mid, lo, str, lcid, __LINE__)
5215 CHECKPTR(VarBstrFromDec
);
5217 en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5218 sp
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5220 BSTR_DEC(0,0,0,0, "0", en_us
);
5222 BSTR_DEC(0,0,0,1, "1", en_us
);
5223 BSTR_DEC(1,0,0,10, "1", en_us
);
5224 BSTR_DEC(2,0,0,100, "1", en_us
);
5225 BSTR_DEC(3,0,0,1000,"1", en_us
);
5227 BSTR_DEC(1,0,0,15, "1.5", en_us
);
5228 BSTR_DEC(2,0,0,150, "1.5", en_us
);
5229 BSTR_DEC(3,0,0,1500,"1.5", en_us
);
5231 BSTR_DEC(1,0x80,0,15, "-1.5", en_us
);
5234 BSTR_DEC(0,0,0,0xffffffff, "4294967295", en_us
);
5236 BSTR_DEC64(0,0,0,1,0, "4294967296", en_us
);
5238 BSTR_DEC64(0,0,0,0xffffffff,0xffffffff, "18446744073709551615", en_us
);
5240 BSTR_DEC(0,0,1,0, "18446744073709551616", en_us
);
5242 BSTR_DEC64(0,0,0xffffffff,0xffffffff,0xffffffff, "79228162514264337593543950335", en_us
);
5244 BSTR_DEC(10,0,0,1, "0.0000000001", en_us
);
5245 /* ((1 << 96) - 1) * 10^-10 */
5246 BSTR_DEC64(10,0,0xffffffffUL
,0xffffffff,0xffffffff, "7922816251426433759.3543950335", en_us
);
5247 /* ((1 << 96) - 1) * 10^-28 */
5248 BSTR_DEC64(28,0,0xffffffffUL
,0xffffffff,0xffffffff, "7.9228162514264337593543950335", en_us
);
5250 /* check leading zeros and decimal sep. for English locale */
5251 BSTR_DEC(4,0,0,9, "0.0009", en_us
);
5252 BSTR_DEC(5,0,0,90, "0.0009", en_us
);
5253 BSTR_DEC(6,0,0,900, "0.0009", en_us
);
5254 BSTR_DEC(7,0,0,9000, "0.0009", en_us
);
5256 /* check leading zeros and decimal sep. for Spanish locale */
5257 BSTR_DEC(4,0,0,9, "0,0009", sp
);
5258 BSTR_DEC(5,0,0,90, "0,0009", sp
);
5259 BSTR_DEC(6,0,0,900, "0,0009", sp
);
5260 BSTR_DEC(7,0,0,9000, "0,0009", sp
);
5266 #define _VARBSTRCMP(left,right,lcid,flags,result) \
5267 hres = pVarBstrCmp(left,right,lcid,flags); \
5268 ok(hres == result, "VarBstrCmp: expected " #result ", got hres=0x%x\n", hres)
5269 #define VARBSTRCMP(left,right,flags,result) \
5270 _VARBSTRCMP(left,right,lcid,flags,result)
5272 static void test_VarBstrCmp(void)
5276 static const WCHAR sz
[] = {'W','u','r','s','c','h','t','\0'};
5277 static const WCHAR szempty
[] = {'\0'};
5278 static const WCHAR sz1
[] = { 'a',0 };
5279 static const WCHAR sz2
[] = { 'A',0 };
5280 static const WCHAR s1
[] = { 'a',0 };
5281 static const WCHAR s2
[] = { 'a',0,'b' };
5282 static const char sb1
[] = {1,0,1};
5283 static const char sb2
[] = {1,0,2};
5284 static const char sbchr0
[] = {0,0};
5285 static const char sbchr00
[] = {0,0,0};
5286 BSTR bstr
, bstrempty
, bstr2
;
5288 CHECKPTR(VarBstrCmp
);
5290 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5291 bstr
= SysAllocString(sz
);
5292 bstrempty
= SysAllocString(szempty
);
5294 /* NULL handling. Yepp, MSDN is totally wrong here */
5295 VARBSTRCMP(NULL
,NULL
,0,VARCMP_EQ
);
5296 VARBSTRCMP(bstr
,NULL
,0,VARCMP_GT
);
5297 VARBSTRCMP(NULL
,bstr
,0,VARCMP_LT
);
5299 /* NULL and empty string comparisons */
5300 VARBSTRCMP(bstrempty
,NULL
,0,VARCMP_EQ
);
5301 VARBSTRCMP(NULL
,bstrempty
,0,VARCMP_EQ
);
5303 SysFreeString(bstr
);
5304 bstr
= SysAllocString(sz1
);
5306 bstr2
= SysAllocString(sz2
);
5307 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5308 VARBSTRCMP(bstr
,bstr2
,NORM_IGNORECASE
,VARCMP_EQ
);
5309 SysFreeString(bstr2
);
5310 /* These two strings are considered equal even though one is
5311 * NULL-terminated and the other not.
5313 bstr2
= SysAllocStringLen(s1
, sizeof(s1
) / sizeof(WCHAR
));
5314 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_EQ
);
5315 SysFreeString(bstr2
);
5317 /* These two strings are not equal */
5318 bstr2
= SysAllocStringLen(s2
, sizeof(s2
) / sizeof(WCHAR
));
5319 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5320 SysFreeString(bstr2
);
5322 SysFreeString(bstr
);
5324 bstr
= SysAllocStringByteLen(sbchr0
, sizeof(sbchr0
));
5325 bstr2
= SysAllocStringByteLen(sbchr00
, sizeof(sbchr00
));
5326 VARBSTRCMP(bstr
,bstrempty
,0,VARCMP_GT
);
5327 VARBSTRCMP(bstrempty
,bstr
,0,VARCMP_LT
);
5328 VARBSTRCMP(bstr2
,bstrempty
,0,VARCMP_GT
);
5329 VARBSTRCMP(bstr2
,bstr
,0,VARCMP_EQ
);
5330 SysFreeString(bstr2
);
5331 SysFreeString(bstr
);
5333 /* When (LCID == 0) it should be a binary comparison
5334 * so these two strings could not match.
5336 bstr
= SysAllocStringByteLen(sb1
, sizeof(sb1
));
5337 bstr2
= SysAllocStringByteLen(sb2
, sizeof(sb2
));
5339 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5340 SysFreeString(bstr2
);
5341 SysFreeString(bstr
);
5343 bstr
= SysAllocStringByteLen(sbchr0
, sizeof(sbchr0
));
5344 bstr2
= SysAllocStringByteLen(sbchr00
, sizeof(sbchr00
));
5345 VARBSTRCMP(bstr
,bstrempty
,0,VARCMP_GT
);
5346 VARBSTRCMP(bstrempty
,bstr
,0,VARCMP_LT
);
5347 VARBSTRCMP(bstr2
,bstrempty
,0,VARCMP_GT
);
5348 VARBSTRCMP(bstr2
,bstr
,0,VARCMP_GT
);
5349 SysFreeString(bstr2
);
5350 SysFreeString(bstr
);
5351 SysFreeString(bstrempty
);
5354 /* Get the internal representation of a BSTR */
5355 static inline LPINTERNAL_BSTR
Get(const BSTR lpszString
)
5357 return lpszString
? (LPINTERNAL_BSTR
)((char*)lpszString
- sizeof(DWORD
)) : NULL
;
5360 static inline BSTR
GetBSTR(const LPINTERNAL_BSTR bstr
)
5362 return (BSTR
)bstr
->szString
;
5365 static void test_SysStringLen(void)
5368 BSTR str
= GetBSTR(&bstr
);
5371 ok (SysStringLen(str
) == 0, "Expected dwLen 0, got %d\n", SysStringLen(str
));
5373 ok (SysStringLen(str
) == 1, "Expected dwLen 1, got %d\n", SysStringLen(str
));
5376 static void test_SysStringByteLen(void)
5379 BSTR str
= GetBSTR(&bstr
);
5382 ok (SysStringByteLen(str
) == 0, "Expected dwLen 0, got %d\n", SysStringByteLen(str
));
5384 ok (SysStringByteLen(str
) == 2, "Expected dwLen 2, got %d\n", SysStringByteLen(str
));
5387 static void test_SysAllocString(void)
5389 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5392 str
= SysAllocString(NULL
);
5393 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5395 str
= SysAllocString(szTest
);
5396 ok (str
!= NULL
, "Expected non-NULL\n");
5399 LPINTERNAL_BSTR bstr
= Get(str
);
5401 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5402 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5407 static void test_SysAllocStringLen(void)
5409 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5412 /* Very early native dlls do not limit the size of strings, so skip this test */
5415 str
= SysAllocStringLen(szTest
, 0x80000000);
5416 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5419 str
= SysAllocStringLen(NULL
, 0);
5420 ok (str
!= NULL
, "Expected non-NULL\n");
5423 LPINTERNAL_BSTR bstr
= Get(str
);
5425 ok (bstr
->dwLen
== 0, "Expected 0, got %d\n", bstr
->dwLen
);
5426 ok (!bstr
->szString
[0], "String not empty\n");
5430 str
= SysAllocStringLen(szTest
, 4);
5431 ok (str
!= NULL
, "Expected non-NULL\n");
5434 LPINTERNAL_BSTR bstr
= Get(str
);
5436 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5437 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5442 static void test_SysAllocStringByteLen(void)
5444 const OLECHAR szTest
[10] = { 'T','e','s','t','\0' };
5445 const CHAR szTestA
[6] = { 'T','e','s','t','\0','?' };
5448 if (sizeof(void *) == 4) /* not limited to 0x80000000 on Win64 */
5450 str
= SysAllocStringByteLen(szTestA
, 0x80000000);
5451 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5454 str
= SysAllocStringByteLen(szTestA
, 0xffffffff);
5455 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5457 str
= SysAllocStringByteLen(NULL
, 0);
5458 ok (str
!= NULL
, "Expected non-NULL\n");
5461 LPINTERNAL_BSTR bstr
= Get(str
);
5463 ok (bstr
->dwLen
== 0, "Expected 0, got %d\n", bstr
->dwLen
);
5464 ok (!bstr
->szString
[0], "String not empty\n");
5468 str
= SysAllocStringByteLen(szTestA
, 4);
5469 ok (str
!= NULL
, "Expected non-NULL\n");
5472 LPINTERNAL_BSTR bstr
= Get(str
);
5474 ok (bstr
->dwLen
== 4, "Expected 4, got %d\n", bstr
->dwLen
);
5475 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestA
), "String different\n");
5479 /* Odd lengths are allocated rounded up, but truncated at the right position */
5480 str
= SysAllocStringByteLen(szTestA
, 3);
5481 ok (str
!= NULL
, "Expected non-NULL\n");
5484 const CHAR szTestTruncA
[4] = { 'T','e','s','\0' };
5485 LPINTERNAL_BSTR bstr
= Get(str
);
5487 ok (bstr
->dwLen
== 3, "Expected 3, got %d\n", bstr
->dwLen
);
5488 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestTruncA
), "String different\n");
5492 str
= SysAllocStringByteLen((LPCSTR
)szTest
, 8);
5493 ok (str
!= NULL
, "Expected non-NULL\n");
5496 LPINTERNAL_BSTR bstr
= Get(str
);
5498 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5499 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5504 static void test_SysReAllocString(void)
5506 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5507 const OLECHAR szSmaller
[2] = { 'x','\0' };
5508 const OLECHAR szLarger
[7] = { 'L','a','r','g','e','r','\0' };
5511 str
= SysAllocStringLen(szTest
, 4);
5512 ok (str
!= NULL
, "Expected non-NULL\n");
5515 LPINTERNAL_BSTR bstr
;
5519 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5520 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5522 changed
= SysReAllocString(&str
, szSmaller
);
5523 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5524 /* Vista creates a new string, but older versions reuse the existing string. */
5525 /*ok (str == oldstr, "Created new string\n");*/
5527 ok (bstr
->dwLen
== 2, "Expected 2, got %d\n", bstr
->dwLen
);
5528 ok (!lstrcmpW(bstr
->szString
, szSmaller
), "String different\n");
5530 changed
= SysReAllocString(&str
, szLarger
);
5531 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5532 /* Early versions always make new strings rather than resizing */
5533 /* ok (str == oldstr, "Created new string\n"); */
5535 ok (bstr
->dwLen
== 12, "Expected 12, got %d\n", bstr
->dwLen
);
5536 ok (!lstrcmpW(bstr
->szString
, szLarger
), "String different\n");
5542 static void test_SysReAllocStringLen(void)
5544 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5545 const OLECHAR szSmaller
[2] = { 'x','\0' };
5546 const OLECHAR szLarger
[7] = { 'L','a','r','g','e','r','\0' };
5549 str
= SysAllocStringLen(szTest
, 4);
5550 ok (str
!= NULL
, "Expected non-NULL\n");
5553 LPINTERNAL_BSTR bstr
;
5557 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5558 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5560 changed
= SysReAllocStringLen(&str
, szSmaller
, 1);
5561 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5562 /* Vista creates a new string, but older versions reuse the existing string. */
5563 /*ok (str == oldstr, "Created new string\n");*/
5565 ok (bstr
->dwLen
== 2, "Expected 2, got %d\n", bstr
->dwLen
);
5566 ok (!lstrcmpW(bstr
->szString
, szSmaller
), "String different\n");
5568 changed
= SysReAllocStringLen(&str
, szLarger
, 6);
5569 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5570 /* Early versions always make new strings rather than resizing */
5571 /* ok (str == oldstr, "Created new string\n"); */
5573 ok (bstr
->dwLen
== 12, "Expected 12, got %d\n", bstr
->dwLen
);
5574 ok (!lstrcmpW(bstr
->szString
, szLarger
), "String different\n");
5576 changed
= SysReAllocStringLen(&str
, str
, 6);
5577 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5582 /* Windows always returns null terminated strings */
5583 str
= SysAllocStringLen(szTest
, 4);
5584 ok (str
!= NULL
, "Expected non-NULL\n");
5587 const int CHUNK_SIZE
= 64;
5588 const int STRING_SIZE
= 24;
5590 changed
= SysReAllocStringLen(&str
, NULL
, CHUNK_SIZE
);
5591 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5592 ok (str
!= NULL
, "Expected non-NULL\n");
5597 /* Filling string */
5598 memset (str
, 0xAB, CHUNK_SIZE
* sizeof (OLECHAR
));
5599 /* Checking null terminator */
5600 changed
= SysReAllocStringLen(&str
, NULL
, STRING_SIZE
);
5601 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5602 ok (str
!= NULL
, "Expected non-NULL\n");
5605 ok (str
== oldstr
, "Expected reuse of the old string memory\n");
5606 ok (str
[STRING_SIZE
] == 0,
5607 "Expected null terminator, got 0x%04X\n", str
[STRING_SIZE
]);
5613 /* Some Windows applications use the same pointer for pbstr and psz */
5614 str
= SysAllocStringLen(szTest
, 4);
5615 ok(str
!= NULL
, "Expected non-NULL\n");
5618 SysReAllocStringLen(&str
, str
, 1000000);
5619 ok(SysStringLen(str
)==1000000, "Incorrect string length\n");
5620 ok(!memcmp(szTest
, str
, 4*sizeof(WCHAR
)), "Incorrect string returned\n");
5626 static void test_BstrCopy(void)
5628 const CHAR szTestA
[6] = { 'T','e','s','t','\0','?' };
5629 const CHAR szTestTruncA
[4] = { 'T','e','s','\0' };
5630 LPINTERNAL_BSTR bstr
;
5635 str
= SysAllocStringByteLen(szTestA
, 3);
5636 ok (str
!= NULL
, "Expected non-NULL\n");
5639 V_VT(&vt1
) = VT_BSTR
;
5641 V_VT(&vt2
) = VT_EMPTY
;
5642 hres
= VariantCopy(&vt2
, &vt1
);
5643 ok (hres
== S_OK
,"Failed to copy binary bstring with hres 0x%08x\n", hres
);
5644 bstr
= Get(V_BSTR(&vt2
));
5645 ok (bstr
->dwLen
== 3, "Expected 3, got %d\n", bstr
->dwLen
);
5646 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestTruncA
), "String different\n");
5652 static void test_VarBstrCat(void)
5654 static const WCHAR sz1
[] = { 'a',0 };
5655 static const WCHAR sz2
[] = { 'b',0 };
5656 static const WCHAR sz1sz2
[] = { 'a','b',0 };
5657 static const WCHAR s1
[] = { 'a',0 };
5658 static const WCHAR s2
[] = { 'b',0 };
5659 static const WCHAR s1s2
[] = { 'a',0,'b',0 };
5660 static const char str1A
[] = "Have ";
5661 static const char str2A
[] = "A Cigar";
5663 BSTR str1
, str2
, res
;
5666 CHECKPTR(VarBstrCat
);
5671 pVarBstrCat(NULL
, NULL
, NULL
);
5674 /* Concatenation of two NULL strings works */
5675 ret
= pVarBstrCat(NULL
, NULL
, &res
);
5676 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5677 ok(res
!= NULL
, "Expected a string\n");
5678 ok(SysStringLen(res
) == 0, "Expected a 0-length string\n");
5681 str1
= SysAllocString(sz1
);
5683 /* Concatenation with one NULL arg */
5684 ret
= pVarBstrCat(NULL
, str1
, &res
);
5685 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5686 ok(res
!= NULL
, "Expected a string\n");
5687 ok(SysStringLen(res
) == SysStringLen(str1
), "Unexpected length\n");
5688 ok(!memcmp(res
, sz1
, SysStringLen(str1
)), "Unexpected value\n");
5690 ret
= pVarBstrCat(str1
, NULL
, &res
);
5691 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5692 ok(res
!= NULL
, "Expected a string\n");
5693 ok(SysStringLen(res
) == SysStringLen(str1
), "Unexpected length\n");
5694 ok(!memcmp(res
, sz1
, SysStringLen(str1
)), "Unexpected value\n");
5697 /* Concatenation of two zero-terminated strings */
5698 str2
= SysAllocString(sz2
);
5699 ret
= pVarBstrCat(str1
, str2
, &res
);
5700 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5701 ok(res
!= NULL
, "Expected a string\n");
5702 ok(SysStringLen(res
) == sizeof(sz1sz2
) / sizeof(WCHAR
) - 1,
5703 "Unexpected length\n");
5704 ok(!memcmp(res
, sz1sz2
, sizeof(sz1sz2
)), "Unexpected value\n");
5707 SysFreeString(str2
);
5708 SysFreeString(str1
);
5710 /* Concatenation of two strings with embedded NULLs */
5711 str1
= SysAllocStringLen(s1
, sizeof(s1
) / sizeof(WCHAR
));
5712 str2
= SysAllocStringLen(s2
, sizeof(s2
) / sizeof(WCHAR
));
5714 ret
= pVarBstrCat(str1
, str2
, &res
);
5715 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5716 ok(res
!= NULL
, "Expected a string\n");
5717 ok(SysStringLen(res
) == sizeof(s1s2
) / sizeof(WCHAR
),
5718 "Unexpected length\n");
5719 ok(!memcmp(res
, s1s2
, sizeof(s1s2
)), "Unexpected value\n");
5722 SysFreeString(str2
);
5723 SysFreeString(str1
);
5725 /* Concatenation of ansi BSTRs, both odd byte count not including termination */
5726 str1
= SysAllocStringByteLen(str1A
, sizeof(str1A
)-1);
5727 str2
= SysAllocStringByteLen(str2A
, sizeof(str2A
)-1);
5728 len
= SysStringLen(str1
);
5729 ok(len
== (sizeof(str1A
)-1)/sizeof(WCHAR
), "got length %u\n", len
);
5730 len
= SysStringLen(str2
);
5731 ok(len
== (sizeof(str2A
)-1)/sizeof(WCHAR
), "got length %u\n", len
);
5733 ret
= pVarBstrCat(str1
, str2
, &res
);
5734 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5735 ok(res
!= NULL
, "Expected a string\n");
5736 len
= (sizeof(str1A
) + sizeof(str2A
) - 2)/sizeof(WCHAR
);
5737 ok(SysStringLen(res
) == len
, "got %d, expected %u\n", SysStringLen(res
), len
);
5738 ok(!memcmp(res
, "Have A Cigar", sizeof(str1A
) + sizeof(str2A
) - 1), "got (%s)\n", (char*)res
);
5741 SysFreeString(str2
);
5742 SysFreeString(str1
);
5744 /* Concatenation of ansi BSTRs, both 1 byte length not including termination */
5745 str1
= SysAllocStringByteLen(str1A
, 1);
5746 str2
= SysAllocStringByteLen(str2A
, 1);
5747 len
= SysStringLen(str1
);
5748 ok(len
== 0, "got length %u\n", len
);
5749 len
= SysStringLen(str2
);
5750 ok(len
== 0, "got length %u\n", len
);
5752 ret
= pVarBstrCat(str1
, str2
, &res
);
5753 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5754 ok(res
!= NULL
, "Expected a string\n");
5755 ok(SysStringLen(res
) == 1, "got %d, expected 1\n", SysStringLen(res
));
5756 ok(!memcmp(res
, "HA", 2), "got (%s)\n", (char*)res
);
5759 SysFreeString(str2
);
5760 SysFreeString(str1
);
5765 static void test_IUnknownClear(void)
5772 init_test_dispatch(1, VT_UI1
, &u
);
5773 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5775 /* Test that IUnknown_Release is called on by-value */
5776 V_VT(&v
) = VT_UNKNOWN
;
5777 V_UNKNOWN(&v
) = (IUnknown
*)&u
.IDispatch_iface
;
5778 hres
= VariantClear(&v
);
5779 ok(hres
== S_OK
&& u
.ref
== 0 && V_VT(&v
) == VT_EMPTY
,
5780 "clear unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5781 S_OK
, 0, VT_EMPTY
, hres
, u
.ref
, V_VT(&v
));
5783 /* But not when clearing a by-reference*/
5785 V_VT(&v
) = VT_UNKNOWN
|VT_BYREF
;
5786 V_UNKNOWNREF(&v
) = &pu
;
5787 hres
= VariantClear(&v
);
5788 ok(hres
== S_OK
&& u
.ref
== 1 && V_VT(&v
) == VT_EMPTY
,
5789 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5790 S_OK
, 1, VT_EMPTY
, hres
, u
.ref
, V_VT(&v
));
5793 static void test_IUnknownCopy(void)
5796 VARIANTARG vSrc
, vDst
;
5800 init_test_dispatch(1, VT_UI1
, &u
);
5801 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5803 /* AddRef is called on by-value copy */
5805 V_VT(&vSrc
) = VT_UNKNOWN
;
5806 V_UNKNOWN(&vSrc
) = pu
;
5807 hres
= VariantCopy(&vDst
, &vSrc
);
5808 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vDst
) == VT_UNKNOWN
,
5809 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5810 S_OK
, 2, VT_EMPTY
, hres
, u
.ref
, V_VT(&vDst
));
5812 /* AddRef is skipped on copy of by-reference IDispatch */
5815 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5816 V_UNKNOWNREF(&vSrc
) = &pu
;
5817 hres
= VariantCopy(&vDst
, &vSrc
);
5818 ok(hres
== S_OK
&& u
.ref
== 1 && V_VT(&vDst
) == (VT_UNKNOWN
|VT_BYREF
),
5819 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5820 S_OK
, 1, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vDst
));
5822 /* AddRef is called copying by-reference IDispatch with indirection */
5825 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5826 V_UNKNOWNREF(&vSrc
) = &pu
;
5827 hres
= VariantCopyInd(&vDst
, &vSrc
);
5828 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vDst
) == VT_UNKNOWN
,
5829 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5830 S_OK
, 2, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vDst
));
5832 /* Indirection in place also calls AddRef */
5834 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5835 V_UNKNOWNREF(&vSrc
) = &pu
;
5836 hres
= VariantCopyInd(&vSrc
, &vSrc
);
5837 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vSrc
) == VT_UNKNOWN
,
5838 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5839 S_OK
, 2, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vSrc
));
5842 static void test_IUnknownChangeTypeEx(void)
5845 VARIANTARG vSrc
, vDst
;
5851 init_test_dispatch(1, VT_UI1
, &u
);
5852 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5854 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5856 V_VT(&vSrc
) = VT_UNKNOWN
;
5857 V_UNKNOWN(&vSrc
) = pu
;
5859 /* =>IDispatch in place */
5860 hres
= VariantChangeTypeEx(&vSrc
, &vSrc
, lcid
, 0, VT_DISPATCH
);
5861 ok(hres
== S_OK
&& u
.ref
== 1 &&
5862 V_VT(&vSrc
) == VT_DISPATCH
&& V_DISPATCH(&vSrc
) == (IDispatch
*)pu
,
5863 "change unk(src=src): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
5864 S_OK
, 1, VT_DISPATCH
, pu
, hres
, u
.ref
, V_VT(&vSrc
), V_DISPATCH(&vSrc
));
5868 V_VT(&vSrc
) = VT_UNKNOWN
;
5869 V_UNKNOWN(&vSrc
) = pu
;
5871 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
5872 /* Note vSrc is not cleared, as final refcount is 2 */
5873 ok(hres
== S_OK
&& u
.ref
== 2 &&
5874 V_VT(&vDst
) == VT_UNKNOWN
&& V_UNKNOWN(&vDst
) == pu
,
5875 "change unk(src,dst): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
5876 S_OK
, 2, VT_UNKNOWN
, pu
, hres
, u
.ref
, V_VT(&vDst
), V_UNKNOWN(&vDst
));
5878 /* Can't change unknown to anything else */
5879 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
5881 HRESULT hExpected
= DISP_E_BADVARTYPE
;
5883 V_VT(&vSrc
) = VT_UNKNOWN
;
5884 V_UNKNOWN(&vSrc
) = pu
;
5887 if (vt
== VT_UNKNOWN
|| vt
== VT_DISPATCH
|| vt
== VT_EMPTY
|| vt
== VT_NULL
)
5891 if (vt
== VT_I8
|| vt
== VT_UI8
)
5894 hExpected
= DISP_E_TYPEMISMATCH
;
5896 else if (vt
== VT_RECORD
)
5898 hExpected
= DISP_E_TYPEMISMATCH
;
5900 else if (vt
>= VT_I2
&& vt
<= VT_UINT
&& vt
!= (VARTYPE
)15)
5901 hExpected
= DISP_E_TYPEMISMATCH
;
5904 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
5905 ok(hres
== hExpected
,
5906 "change unk(badvar): vt %d expected 0x%08x, got 0x%08x\n",
5907 vt
, hExpected
, hres
);
5912 static void test_IDispatchClear(void)
5919 init_test_dispatch(1, VT_UI1
, &d
);
5920 pd
= &d
.IDispatch_iface
;
5922 /* As per IUnknown */
5924 V_VT(&v
) = VT_DISPATCH
;
5925 V_DISPATCH(&v
) = pd
;
5926 hres
= VariantClear(&v
);
5927 ok(hres
== S_OK
&& d
.ref
== 0 && V_VT(&v
) == VT_EMPTY
,
5928 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5929 S_OK
, 0, VT_EMPTY
, hres
, d
.ref
, V_VT(&v
));
5932 V_VT(&v
) = VT_DISPATCH
|VT_BYREF
;
5933 V_DISPATCHREF(&v
) = &pd
;
5934 hres
= VariantClear(&v
);
5935 ok(hres
== S_OK
&& d
.ref
== 1 && V_VT(&v
) == VT_EMPTY
,
5936 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5937 S_OK
, 1, VT_EMPTY
, hres
, d
.ref
, V_VT(&v
));
5940 static void test_IDispatchCopy(void)
5943 VARIANTARG vSrc
, vDst
;
5947 init_test_dispatch(1, VT_UI1
, &d
);
5948 pd
= &d
.IDispatch_iface
;
5950 /* As per IUnknown */
5953 V_VT(&vSrc
) = VT_DISPATCH
;
5954 V_DISPATCH(&vSrc
) = pd
;
5955 hres
= VariantCopy(&vDst
, &vSrc
);
5956 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vDst
) == VT_DISPATCH
,
5957 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5958 S_OK
, 2, VT_EMPTY
, hres
, d
.ref
, V_VT(&vDst
));
5962 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
5963 V_DISPATCHREF(&vSrc
) = &pd
;
5964 hres
= VariantCopy(&vDst
, &vSrc
);
5965 ok(hres
== S_OK
&& d
.ref
== 1 && V_VT(&vDst
) == (VT_DISPATCH
|VT_BYREF
),
5966 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5967 S_OK
, 1, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vDst
));
5971 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
5972 V_DISPATCHREF(&vSrc
) = &pd
;
5973 hres
= VariantCopyInd(&vDst
, &vSrc
);
5974 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vDst
) == VT_DISPATCH
,
5975 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5976 S_OK
, 2, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vDst
));
5979 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
5980 V_DISPATCHREF(&vSrc
) = &pd
;
5981 hres
= VariantCopyInd(&vSrc
, &vSrc
);
5982 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vSrc
) == VT_DISPATCH
,
5983 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5984 S_OK
, 2, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vSrc
));
5987 static void test_IDispatchChangeTypeEx(void)
5990 VARIANTARG vSrc
, vDst
;
5995 init_test_dispatch(1, VT_UI1
, &d
);
5996 pd
= &d
.IDispatch_iface
;
5998 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6000 V_VT(&vSrc
) = VT_DISPATCH
;
6001 V_DISPATCH(&vSrc
) = pd
;
6003 /* =>IUnknown in place */
6004 hres
= VariantChangeTypeEx(&vSrc
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
6005 ok(hres
== S_OK
&& d
.ref
== 1 &&
6006 V_VT(&vSrc
) == VT_UNKNOWN
&& V_UNKNOWN(&vSrc
) == (IUnknown
*)pd
,
6007 "change disp(src=src): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
6008 S_OK
, 1, VT_UNKNOWN
, pd
, hres
, d
.ref
, V_VT(&vSrc
), V_UNKNOWN(&vSrc
));
6012 V_VT(&vSrc
) = VT_DISPATCH
;
6013 V_DISPATCH(&vSrc
) = pd
;
6015 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
6016 /* Note vSrc is not cleared, as final refcount is 2 */
6017 ok(hres
== S_OK
&& d
.ref
== 2 &&
6018 V_VT(&vDst
) == VT_UNKNOWN
&& V_UNKNOWN(&vDst
) == (IUnknown
*)pd
,
6019 "change disp(src,dst): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
6020 S_OK
, 2, VT_UNKNOWN
, pd
, hres
, d
.ref
, V_VT(&vDst
), V_UNKNOWN(&vDst
));
6022 /* FIXME: Verify that VARIANT_NOVALUEPROP prevents conversion to integral
6023 * types. this requires that the xxxFromDisp tests work first.
6028 static void test_ErrorChangeTypeEx(void)
6031 VARIANTARG vSrc
, vDst
;
6035 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6037 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
6039 HRESULT hExpected
= DISP_E_BADVARTYPE
;
6041 V_VT(&vSrc
) = VT_ERROR
;
6044 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6050 if (vt
== VT_I8
|| vt
== VT_UI8
)
6053 hExpected
= DISP_E_TYPEMISMATCH
;
6055 else if (vt
== VT_RECORD
)
6057 hExpected
= DISP_E_TYPEMISMATCH
;
6059 else if (vt
<= VT_UINT
&& vt
!= (VARTYPE
)15)
6060 hExpected
= DISP_E_TYPEMISMATCH
;
6063 ok(hres
== hExpected
,
6064 "change err: vt %d expected 0x%08x, got 0x%08x\n", vt
, hExpected
, hres
);
6069 static void test_EmptyChangeTypeEx(void)
6074 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6076 for (vt
= VT_EMPTY
; vt
<= VT_BSTR_BLOB
; vt
++)
6078 HRESULT hExpected
, hres
;
6079 VARIANTARG vSrc
, vDst
;
6081 /* skip for undefined types */
6082 if ((vt
== 15) || (vt
> VT_VERSIONED_STREAM
&& vt
< VT_BSTR_BLOB
))
6092 hExpected
= DISP_E_BADVARTYPE
;
6099 hExpected
= DISP_E_TYPEMISMATCH
;
6121 hExpected
= DISP_E_BADVARTYPE
;
6125 V_VT(&vSrc
) = VT_EMPTY
;
6126 memset(&vDst
, 0, sizeof(vDst
));
6127 V_VT(&vDst
) = VT_NULL
;
6129 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6130 ok(hres
== hExpected
, "change empty: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6131 vt
, hExpected
, hres
, V_VT(&vDst
));
6134 ok(V_VT(&vDst
) == vt
, "change empty: vt %d, got %d\n", vt
, V_VT(&vDst
));
6135 VariantClear(&vDst
);
6141 static void test_NullChangeTypeEx(void)
6146 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6148 for (vt
= VT_EMPTY
; vt
<= VT_BSTR_BLOB
; vt
++)
6150 VARIANTARG vSrc
, vDst
;
6151 HRESULT hExpected
, hres
;
6153 /* skip for undefined types */
6154 if ((vt
== 15) || (vt
> VT_VERSIONED_STREAM
&& vt
< VT_BSTR_BLOB
))
6162 hExpected
= DISP_E_TYPEMISMATCH
;
6164 hExpected
= DISP_E_BADVARTYPE
;
6190 hExpected
= DISP_E_TYPEMISMATCH
;
6193 hExpected
= DISP_E_BADVARTYPE
;
6197 V_VT(&vSrc
) = VT_NULL
;
6198 memset(&vDst
, 0, sizeof(vDst
));
6199 V_VT(&vDst
) = VT_EMPTY
;
6201 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6202 ok(hres
== hExpected
, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6203 vt
, hExpected
, hres
, V_VT(&vDst
));
6205 /* should work only for VT_NULL -> VT_NULL case */
6207 ok(V_VT(&vDst
) == VT_NULL
, "change null: VT_NULL expected 0x%08x, got 0x%08x, vt %d\n",
6208 hExpected
, hres
, V_VT(&vDst
));
6210 ok(V_VT(&vDst
) == VT_EMPTY
, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6211 vt
, hExpected
, hres
, V_VT(&vDst
));
6217 static void test_UintChangeTypeEx(void)
6220 VARIANTARG vSrc
, vDst
;
6223 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6225 /* Converting a VT_UINT to a VT_INT does not check for overflow */
6226 V_VT(&vDst
) = VT_EMPTY
;
6227 V_VT(&vSrc
) = VT_UINT
;
6229 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_I4
);
6230 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == -1,
6231 "change uint: Expected %d,0x%08x,%d got %d,0x%08x,%d\n",
6232 VT_I4
, S_OK
, -1, V_VT(&vDst
), hres
, V_I4(&vDst
));
6235 #define NUM_CUST_ITEMS 16
6237 static void test_ClearCustData(void)
6242 CHECKPTR(ClearCustData
);
6244 ci
.cCustData
= NUM_CUST_ITEMS
;
6245 ci
.prgCustData
= CoTaskMemAlloc( sizeof(CUSTDATAITEM
) * NUM_CUST_ITEMS
);
6246 for (i
= 0; i
< NUM_CUST_ITEMS
; i
++)
6247 VariantInit(&ci
.prgCustData
[i
].varValue
);
6248 pClearCustData(&ci
);
6249 ok(!ci
.cCustData
&& !ci
.prgCustData
, "ClearCustData didn't clear fields!\n");
6252 static void test_NullByRef(void)
6259 V_VT(&v1
) = VT_BYREF
|VT_VARIANT
;
6262 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_I4
);
6263 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6266 V_VT(&v1
) = VT_BYREF
|VT_VARIANT
;
6271 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_VARIANT
);
6272 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6273 ok(V_VT(&v2
) == VT_I4
&& V_I4(&v2
) == 123, "VariantChangeTypeEx shouldn't change pvargDest\n");
6275 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_BYREF
|VT_I4
);
6276 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6278 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, 0x3847);
6279 ok(hRes
== DISP_E_BADVARTYPE
, "VariantChangeTypeEx should return DISP_E_BADVARTYPE\n");
6282 /* Dst Variant should remain unchanged if VariantChangeType cannot convert */
6283 static void test_ChangeType_keep_dst(void)
6287 static const WCHAR testW
[] = {'t','e','s','t',0};
6290 bstr
= SysAllocString(testW
);
6293 V_VT(&v1
) = VT_BSTR
;
6295 hres
= VariantChangeTypeEx(&v1
, &v1
, 0, 0, VT_INT
);
6296 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6297 ok(V_VT(&v1
) == VT_BSTR
&& V_BSTR(&v1
) == bstr
, "VariantChangeTypeEx changed dst variant\n");
6300 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_INT
);
6301 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6302 ok(V_VT(&v2
) == VT_INT
&& V_INT(&v2
) == 4, "VariantChangeTypeEx changed dst variant\n");
6303 V_VT(&v2
) = 0xff; /* incorrect variant type */
6304 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_INT
);
6305 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6306 ok(V_VT(&v2
) == 0xff, "VariantChangeTypeEx changed dst variant\n");
6307 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_BSTR
);
6308 ok(hres
== DISP_E_BADVARTYPE
, "VariantChangeTypeEx returns %08x\n", hres
);
6309 ok(V_VT(&v2
) == 0xff, "VariantChangeTypeEx changed dst variant\n");
6310 SysFreeString(bstr
);
6313 /* This tests assumes an empty cache, so it needs to be ran early in the test. */
6314 static void test_bstr_cache(void)
6316 BSTR str
, str2
, strs
[20];
6319 static const WCHAR testW
[] = {'t','e','s','t',0};
6321 str
= SysAllocString(testW
);
6322 /* This should put the string into cache */
6324 /* The string is in cache, this won't touch it */
6327 ok(SysStringLen(str
) == 4, "unexpected len\n");
6328 ok(!lstrcmpW(str
, testW
), "string changed\n");
6330 str2
= SysAllocString(testW
);
6331 ok(str
== str2
, "str != str2\n");
6332 SysFreeString(str2
);
6334 /* Fill the bucket with cached entries. */
6335 for(i
=0; i
< sizeof(strs
)/sizeof(*strs
); i
++)
6336 strs
[i
] = SysAllocStringLen(NULL
, 24);
6337 for(i
=0; i
< sizeof(strs
)/sizeof(*strs
); i
++)
6338 SysFreeString(strs
[i
]);
6340 /* Following allocation will be made from cache */
6341 str
= SysAllocStringLen(NULL
, 24);
6342 ok(str
== strs
[0], "str != strs[0]\n");
6344 /* Smaller buffers may also use larget cached buffers */
6345 str2
= SysAllocStringLen(NULL
, 16);
6346 ok(str2
== strs
[1], "str2 != strs[1]\n");
6349 SysFreeString(str2
);
6351 SysFreeString(str2
);
6354 static void write_typelib(int res_no
, const char *filename
)
6361 file
= CreateFileA( filename
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0 );
6362 ok( file
!= INVALID_HANDLE_VALUE
, "file creation failed\n" );
6363 if (file
== INVALID_HANDLE_VALUE
) return;
6364 res
= FindResourceA( GetModuleHandleA(NULL
), (LPCSTR
)MAKEINTRESOURCE(res_no
), "TYPELIB" );
6365 ok( res
!= 0, "couldn't find resource\n" );
6366 ptr
= LockResource( LoadResource( GetModuleHandleA(NULL
), res
));
6367 WriteFile( file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
6368 ok( written
== SizeofResource( GetModuleHandleA(NULL
), res
), "couldn't write resource\n" );
6369 CloseHandle( file
);
6372 static const char *create_test_typelib(int res_no
)
6374 static char filename
[MAX_PATH
];
6376 GetTempFileNameA( ".", "tlb", 0, filename
);
6377 write_typelib(res_no
, filename
);
6381 static void test_recinfo(void)
6383 static const WCHAR testW
[] = {'t','e','s','t',0};
6384 static WCHAR teststructW
[] = {'t','e','s','t','_','s','t','r','u','c','t',0};
6385 struct test_struct teststruct
, testcopy
;
6386 WCHAR filenameW
[MAX_PATH
];
6387 const char *filename
;
6388 IRecordInfo
*recinfo
;
6389 ITypeInfo
*typeinfo
;
6390 DummyDispatch dispatch
;
6398 filename
= create_test_typelib(2);
6399 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filenameW
, MAX_PATH
);
6400 hr
= LoadTypeLibEx(filenameW
, REGKIND_NONE
, &typelib
);
6401 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6405 hr
= ITypeLib_FindName(typelib
, teststructW
, 0, &typeinfo
, &memid
, &found
);
6406 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6407 ok(typeinfo
!= NULL
, "got %p\n", typeinfo
);
6408 hr
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
6409 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6410 ok(IsEqualGUID(&attr
->guid
, &UUID_test_struct
), "got %s\n", wine_dbgstr_guid(&attr
->guid
));
6411 ok(attr
->typekind
== TKIND_RECORD
, "got %d\n", attr
->typekind
);
6413 hr
= GetRecordInfoFromTypeInfo(typeinfo
, &recinfo
);
6414 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6417 hr
= IRecordInfo_GetSize(recinfo
, &size
);
6418 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6419 ok(size
== sizeof(struct test_struct
), "got size %d\n", size
);
6420 ok(attr
->cbSizeInstance
== sizeof(struct test_struct
), "got instance size %d\n", attr
->cbSizeInstance
);
6421 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
6424 teststruct
.hr
= E_FAIL
;
6426 teststruct
.disp
= (void*)0xdeadbeef;
6427 teststruct
.bstr
= (void*)0xdeadbeef;
6429 hr
= IRecordInfo_RecordInit(recinfo
, &teststruct
);
6430 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6431 ok(teststruct
.hr
== 0, "got 0x%08x\n", teststruct
.hr
);
6432 ok(teststruct
.b
== 0, "got 0x%08x\n", teststruct
.b
);
6433 ok(teststruct
.disp
== NULL
, "got %p\n", teststruct
.disp
);
6434 ok(teststruct
.bstr
== NULL
, "got %p\n", teststruct
.bstr
);
6436 init_test_dispatch(10, VT_UI1
, &dispatch
);
6438 /* RecordCopy(), interface field reference increased */
6439 teststruct
.hr
= S_FALSE
;
6440 teststruct
.b
= VARIANT_TRUE
;
6441 teststruct
.disp
= &dispatch
.IDispatch_iface
;
6442 teststruct
.bstr
= SysAllocString(testW
);
6443 memset(&testcopy
, 0, sizeof(testcopy
));
6444 hr
= IRecordInfo_RecordCopy(recinfo
, &teststruct
, &testcopy
);
6445 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6446 ok(testcopy
.hr
== S_FALSE
, "got 0x%08x\n", testcopy
.hr
);
6447 ok(testcopy
.b
== VARIANT_TRUE
, "got %d\n", testcopy
.b
);
6448 ok(testcopy
.disp
== teststruct
.disp
, "got %p\n", testcopy
.disp
);
6449 ok(dispatch
.ref
== 11, "got %d\n", dispatch
.ref
);
6450 ok(testcopy
.bstr
!= teststruct
.bstr
, "got %p\n", testcopy
.bstr
);
6451 ok(!lstrcmpW(testcopy
.bstr
, teststruct
.bstr
), "got %s, %s\n", wine_dbgstr_w(testcopy
.bstr
), wine_dbgstr_w(teststruct
.bstr
));
6454 hr
= IRecordInfo_RecordClear(recinfo
, &teststruct
);
6455 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6456 ok(teststruct
.bstr
== NULL
, "got %p\n", teststruct
.bstr
);
6457 hr
= IRecordInfo_RecordClear(recinfo
, &testcopy
);
6458 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6459 ok(testcopy
.bstr
== NULL
, "got %p\n", testcopy
.bstr
);
6461 /* now destination contains inteface pointer */
6462 memset(&testcopy
, 0, sizeof(testcopy
));
6463 testcopy
.disp
= &dispatch
.IDispatch_iface
;
6466 hr
= IRecordInfo_RecordCopy(recinfo
, &teststruct
, &testcopy
);
6467 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6468 ok(dispatch
.ref
== 9, "got %d\n", dispatch
.ref
);
6470 IRecordInfo_Release(recinfo
);
6472 ITypeInfo_Release(typeinfo
);
6473 ITypeLib_Release(typelib
);
6474 DeleteFileA(filename
);
6479 hOleaut32
= GetModuleHandleA("oleaut32.dll");
6481 has_i8
= GetProcAddress(hOleaut32
, "VarI8FromI1") != NULL
;
6482 has_locales
= has_i8
&& GetProcAddress(hOleaut32
, "GetVarConversionLocaleSetting") != NULL
;
6484 trace("LCIDs: System=0x%08x, User=0x%08x\n", GetSystemDefaultLCID(),
6485 GetUserDefaultLCID());
6492 test_VarI1FromUI1();
6493 test_VarI1FromUI2();
6494 test_VarI1FromUI4();
6495 test_VarI1FromUI8();
6496 test_VarI1FromBool();
6499 test_VarI1FromDate();
6501 test_VarI1FromDec();
6502 test_VarI1FromStr();
6503 test_VarUI1FromDisp();
6505 test_VarI1ChangeTypeEx();
6507 test_VarUI1FromI1();
6508 test_VarUI1FromI2();
6509 test_VarUI1FromI4();
6510 test_VarUI1FromI8();
6511 test_VarUI1FromUI2();
6512 test_VarUI1FromUI4();
6513 test_VarUI1FromUI8();
6514 test_VarUI1FromBool();
6515 test_VarUI1FromR4();
6516 test_VarUI1FromR8();
6517 test_VarUI1FromDate();
6518 test_VarUI1FromCy();
6519 test_VarUI1FromDec();
6520 test_VarUI1FromStr();
6522 test_VarUI1ChangeTypeEx();
6527 test_VarI2FromUI1();
6528 test_VarI2FromUI2();
6529 test_VarI2FromUI4();
6530 test_VarI2FromUI8();
6531 test_VarI2FromBool();
6534 test_VarI2FromDate();
6536 test_VarI2FromDec();
6537 test_VarI2FromStr();
6539 test_VarI2ChangeTypeEx();
6541 test_VarUI2FromI1();
6542 test_VarUI2FromI2();
6543 test_VarUI2FromI4();
6544 test_VarUI2FromI8();
6545 test_VarUI2FromUI1();
6546 test_VarUI2FromUI4();
6547 test_VarUI2FromUI8();
6548 test_VarUI2FromBool();
6549 test_VarUI2FromR4();
6550 test_VarUI2FromR8();
6551 test_VarUI2FromDate();
6552 test_VarUI2FromCy();
6553 test_VarUI2FromDec();
6554 test_VarUI2FromStr();
6556 test_VarUI2ChangeTypeEx();
6561 test_VarI4FromUI1();
6562 test_VarI4FromUI2();
6563 test_VarI4FromUI4();
6564 test_VarI4FromUI8();
6565 test_VarI4FromBool();
6568 test_VarI4FromDate();
6570 test_VarI4FromDec();
6571 test_VarI4FromStr();
6573 test_VarI4ChangeTypeEx();
6575 test_VarUI4FromI1();
6576 test_VarUI4FromI2();
6577 test_VarUI4FromUI2();
6578 test_VarUI4FromI8();
6579 test_VarUI4FromUI1();
6580 test_VarUI4FromI4();
6581 test_VarUI4FromUI8();
6582 test_VarUI4FromBool();
6583 test_VarUI4FromR4();
6584 test_VarUI4FromR8();
6585 test_VarUI4FromDate();
6586 test_VarUI4FromCy();
6587 test_VarUI4FromDec();
6588 test_VarUI4FromStr();
6590 test_VarUI4ChangeTypeEx();
6593 test_VarI8FromUI1();
6595 test_VarI8FromUI2();
6596 test_VarI8FromUI4();
6599 test_VarI8FromBool();
6600 test_VarI8FromUI8();
6602 test_VarI8FromDec();
6603 test_VarI8FromDate();
6604 test_VarI8FromStr();
6606 test_VarI8ChangeTypeEx();
6608 test_VarUI8FromI1();
6609 test_VarUI8FromUI1();
6610 test_VarUI8FromI2();
6611 test_VarUI8FromUI2();
6612 test_VarUI8FromUI4();
6613 test_VarUI8FromR4();
6614 test_VarUI8FromR8();
6615 test_VarUI8FromBool();
6616 test_VarUI8FromI8();
6617 test_VarUI8FromCy();
6618 test_VarUI8FromDec();
6619 test_VarUI8FromDate();
6620 test_VarUI8FromStr();
6622 test_VarUI8ChangeTypeEx();
6625 test_VarR4FromUI1();
6627 test_VarR4FromUI2();
6629 test_VarR4FromUI4();
6631 test_VarR4FromBool();
6634 test_VarR4FromUI8();
6635 test_VarR4FromDec();
6636 test_VarR4FromDate();
6637 test_VarR4FromStr();
6639 test_VarR4ChangeTypeEx();
6642 test_VarR8FromUI1();
6644 test_VarR8FromUI2();
6646 test_VarR8FromUI4();
6648 test_VarR8FromBool();
6651 test_VarR8FromUI8();
6652 test_VarR8FromDec();
6653 test_VarR8FromDate();
6654 test_VarR8FromStr();
6656 test_VarR8ChangeTypeEx();
6659 test_VarDateFromI1();
6660 test_VarDateFromUI1();
6661 test_VarDateFromI2();
6662 test_VarDateFromUI2();
6663 test_VarDateFromI4();
6664 test_VarDateFromUI4();
6665 test_VarDateFromR4();
6666 test_VarDateFromR8();
6667 test_VarDateFromBool();
6668 test_VarDateFromCy();
6669 test_VarDateFromI8();
6670 test_VarDateFromUI8();
6671 test_VarDateFromDec();
6672 test_VarDateFromStr();
6674 test_VarDateChangeTypeEx();
6677 test_VarCyFromUI1();
6679 test_VarCyFromUI2();
6681 test_VarCyFromUI4();
6684 test_VarCyFromBool();
6686 test_VarCyFromUI8();
6687 test_VarCyFromDec();
6688 test_VarCyFromDate();
6703 test_VarDecFromI1();
6704 test_VarDecFromI2();
6705 test_VarDecFromI4();
6706 test_VarDecFromI8();
6707 test_VarDecFromUI1();
6708 test_VarDecFromUI2();
6709 test_VarDecFromUI4();
6710 test_VarDecFromUI8();
6711 test_VarDecFromR4();
6712 test_VarDecFromR8();
6713 test_VarDecFromDate();
6714 test_VarDecFromStr();
6715 test_VarDecFromCy();
6716 test_VarDecFromDate();
6717 test_VarDecFromBool();
6729 test_VarBoolFromI1();
6730 test_VarBoolFromUI1();
6731 test_VarBoolFromI2();
6732 test_VarBoolFromUI2();
6733 test_VarBoolFromI4();
6734 test_VarBoolFromUI4();
6735 test_VarBoolFromR4();
6736 test_VarBoolFromR8();
6737 test_VarBoolFromCy();
6738 test_VarBoolFromI8();
6739 test_VarBoolFromUI8();
6740 test_VarBoolFromDec();
6741 test_VarBoolFromDate();
6742 test_VarBoolFromStr();
6744 test_VarBoolChangeTypeEx();
6746 test_VarBstrFromR4();
6747 test_VarBstrFromDate();
6748 test_VarBstrFromCy();
6749 test_VarBstrFromDec();
6751 test_SysStringLen();
6752 test_SysStringByteLen();
6753 test_SysAllocString();
6754 test_SysAllocStringLen();
6755 test_SysAllocStringByteLen();
6756 test_SysReAllocString();
6757 test_SysReAllocStringLen();
6761 test_IUnknownClear();
6762 test_IUnknownCopy();
6763 test_IUnknownChangeTypeEx();
6765 test_IDispatchClear();
6766 test_IDispatchCopy();
6767 test_IDispatchChangeTypeEx();
6769 test_ErrorChangeTypeEx();
6770 test_EmptyChangeTypeEx();
6771 test_NullChangeTypeEx();
6772 test_UintChangeTypeEx();
6774 test_ClearCustData();
6777 test_ChangeType_keep_dst();