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
);
2893 CONVERT_DEC(VarR4FromDec
,10,0,0,3276700); EXPECT(0.00032767f
);
2895 CONVERT_DEC(VarR4FromDec
,0,0,1,0); EXPECT(18446744073709551616.0f
);
2898 static void test_VarR4FromDate(void)
2902 CHECKPTR(VarR4FromDate
);
2903 CONVERT(VarR4FromDate
, -1.0); EXPECT(-1.0f
);
2904 CONVERT(VarR4FromDate
, 0.0); EXPECT(0.0f
);
2905 CONVERT(VarR4FromDate
, 1.0); EXPECT(1.0f
);
2908 static void test_VarR4FromStr(void)
2913 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
2915 CHECKPTR(VarR4FromStr
);
2917 CONVERT_STR(VarR4FromStr
,NULL
,0); EXPECT_MISMATCH
;
2918 CONVERT_STR(VarR4FromStr
,"-1", 0); EXPECT(-1.0f
);
2919 CONVERT_STR(VarR4FromStr
,"0", 0); EXPECT(0.0f
);
2920 CONVERT_STR(VarR4FromStr
,"1", 0); EXPECT(1.0f
);
2922 CONVERT_STR(VarR4FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-1.5f
);
2923 CONVERT_STR(VarR4FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.6f
);
2924 CONVERT_STR(VarR4FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.5f
);
2925 CONVERT_STR(VarR4FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.4f
);
2926 CONVERT_STR(VarR4FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0.4f
);
2927 CONVERT_STR(VarR4FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0.5f
);
2928 CONVERT_STR(VarR4FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(0.6f
);
2929 CONVERT_STR(VarR4FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(1.5f
);
2932 static void test_VarR4Copy(void)
2934 COPYTEST(77665544.0f
, VT_R4
, V_R4(&vSrc
), V_R4(&vDst
), V_R4REF(&vSrc
),V_R4REF(&vDst
), "%15.15f");
2937 static void test_VarR4ChangeTypeEx(void)
2939 #ifdef HAS_UINT64_TO_FLOAT
2942 VARIANTARG vSrc
, vDst
;
2946 INITIAL_TYPETEST(VT_R4
, V_R4
, "%f");
2956 #define CONV_TYPE double
2958 static void test_VarR8FromI1(void)
2960 CONVVARS(signed char);
2963 CHECKPTR(VarR8FromI1
);
2964 CONVERTRANGE(VarR8FromI1
, -128, 128);
2967 static void test_VarR8FromUI1(void)
2972 CHECKPTR(VarR8FromUI1
);
2973 CONVERTRANGE(VarR8FromUI1
, 0, 256);
2976 static void test_VarR8FromI2(void)
2981 CHECKPTR(VarR8FromI2
);
2982 CONVERTRANGE(VarR8FromI2
, -32768, 32768);
2985 static void test_VarR8FromUI2(void)
2990 CHECKPTR(VarR8FromUI2
);
2991 CONVERTRANGE(VarR8FromUI2
, 0, 65536);
2994 static void test_VarR8FromI4(void)
2998 CHECKPTR(VarR8FromI4
);
2999 CONVERT(VarR8FromI4
, -2147483647-1); EXPECT(-2147483648.0);
3000 CONVERT(VarR8FromI4
, -1); EXPECT(-1.0);
3001 CONVERT(VarR8FromI4
, 0); EXPECT(0.0);
3002 CONVERT(VarR8FromI4
, 1); EXPECT(1.0);
3003 CONVERT(VarR8FromI4
, 0x7fffffff); EXPECT(2147483647.0);
3006 static void test_VarR8FromUI4(void)
3008 CONVVARS(unsigned int);
3010 CHECKPTR(VarR8FromUI4
);
3011 CONVERT(VarR8FromUI4
, 0); EXPECT(0.0);
3012 CONVERT(VarR8FromUI4
, 1); EXPECT(1.0);
3013 CONVERT(VarR8FromUI4
, 0xffffffff); EXPECT(4294967295.0);
3016 static void test_VarR8FromR4(void)
3020 CHECKPTR(VarR8FromR4
);
3021 CONVERT(VarR8FromR4
, -1.0f
); EXPECT(-1.0);
3022 CONVERT(VarR8FromR4
, 0.0f
); EXPECT(0.0);
3023 CONVERT(VarR8FromR4
, 1.0f
); EXPECT(1.0);
3024 CONVERT(VarR8FromR4
, 1.5f
); EXPECT(1.5);
3026 /* Skip rounding tests - no rounding is done */
3029 static void test_VarR8FromBool(void)
3031 CONVVARS(VARIANT_BOOL
);
3033 CHECKPTR(VarR8FromBool
);
3034 CONVERT(VarR8FromBool
, VARIANT_TRUE
); EXPECT(VARIANT_TRUE
* 1.0);
3035 CONVERT(VarR8FromBool
, VARIANT_FALSE
); EXPECT(VARIANT_FALSE
* 1.0);
3038 static void test_VarR8FromCy(void)
3042 CHECKPTR(VarR8FromCy
);
3043 CONVERT_CY(VarR8FromCy
,-32769); EXPECT(-32769.0);
3044 CONVERT_CY(VarR8FromCy
,-32768); EXPECT(-32768.0);
3045 CONVERT_CY(VarR8FromCy
,-1); EXPECT(-1.0);
3046 CONVERT_CY(VarR8FromCy
,0); EXPECT(0.0);
3047 CONVERT_CY(VarR8FromCy
,1); EXPECT(1.0);
3048 CONVERT_CY(VarR8FromCy
,32767); EXPECT(32767.0);
3049 CONVERT_CY(VarR8FromCy
,32768); EXPECT(32768.0);
3051 CONVERT_CY(VarR8FromCy
,-1.5); EXPECT(-1.5);
3052 CONVERT_CY(VarR8FromCy
,-0.6); EXPECT(-0.6);
3053 CONVERT_CY(VarR8FromCy
,-0.5); EXPECT(-0.5);
3054 CONVERT_CY(VarR8FromCy
,-0.4); EXPECT(-0.4);
3055 CONVERT_CY(VarR8FromCy
,0.4); EXPECT(0.4);
3056 CONVERT_CY(VarR8FromCy
,0.5); EXPECT(0.5);
3057 CONVERT_CY(VarR8FromCy
,0.6); EXPECT(0.6);
3058 CONVERT_CY(VarR8FromCy
,1.5); EXPECT(1.5);
3061 static void test_VarR8FromI8(void)
3065 CHECKPTR(VarR8FromI8
);
3066 CONVERT(VarR8FromI8
, -1); EXPECT(-1.0);
3067 CONVERT(VarR8FromI8
, 0); EXPECT(0.0);
3068 CONVERT(VarR8FromI8
, 1); EXPECT(1.0);
3069 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3070 CONVERT_I8(VarR8FromI8
, 0x7fffffff,0xffffffff); EXPECT(9223372036854775808.0);
3074 static void test_VarR8FromUI8(void)
3078 CHECKPTR(VarR8FromUI8
);
3079 CONVERT(VarR8FromUI8
, 0); EXPECT(0.0);
3080 CONVERT(VarR8FromUI8
, 1); EXPECT(1.0);
3081 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3082 CONVERT_I8(VarR8FromUI8
, 0x80000000,0); EXPECT(9223372036854775808.0);
3086 static void test_VarR8FromDec(void)
3090 CHECKPTR(VarR8FromDec
);
3092 CONVERT_BADDEC(VarR8FromDec
);
3094 CONVERT_DEC(VarR8FromDec
,0,0x80,0,32768); EXPECT(-32768.0);
3095 CONVERT_DEC(VarR8FromDec
,0,0x80,0,1); EXPECT(-1.0);
3096 CONVERT_DEC(VarR8FromDec
,0,0,0,0); EXPECT(0.0);
3097 CONVERT_DEC(VarR8FromDec
,0,0,0,1); EXPECT(1.0);
3098 CONVERT_DEC(VarR8FromDec
,0,0,0,32767); EXPECT(32767.0);
3100 CONVERT_DEC(VarR8FromDec
,2,0x80,0,3276800); EXPECT(-32768.0);
3101 CONVERT_DEC(VarR8FromDec
,2,0,0,3276700); EXPECT(32767.0);
3103 CONVERT_DEC(VarR8FromDec
,0,0,1,0); EXPECT(18446744073709551616.0);
3106 static void test_VarR8FromDate(void)
3110 CHECKPTR(VarR8FromDate
);
3111 CONVERT(VarR8FromDate
, -1.0); EXPECT(-1.0);
3112 CONVERT(VarR8FromDate
, -0.0); EXPECT(0.0);
3113 CONVERT(VarR8FromDate
, 1.0); EXPECT(1.0);
3116 static void test_VarR8FromStr(void)
3121 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3123 CHECKPTR(VarR8FromStr
);
3125 CONVERT_STR(VarR8FromStr
,NULL
,0); EXPECT_MISMATCH
;
3126 CONVERT_STR(VarR8FromStr
,"",0); EXPECT_MISMATCH
;
3127 CONVERT_STR(VarR8FromStr
," ",0); EXPECT_MISMATCH
;
3129 CONVERT_STR(VarR8FromStr
,"0",LOCALE_NOUSEROVERRIDE
); EXPECT(0.0);
3130 CONVERT_STR(VarR8FromStr
,"-1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-1.5);
3131 CONVERT_STR(VarR8FromStr
,"-0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.6);
3132 CONVERT_STR(VarR8FromStr
,"-0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.5);
3133 CONVERT_STR(VarR8FromStr
,"-0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(-0.4);
3134 CONVERT_STR(VarR8FromStr
,"0.4",LOCALE_NOUSEROVERRIDE
); EXPECT(0.4);
3135 CONVERT_STR(VarR8FromStr
,"0.5",LOCALE_NOUSEROVERRIDE
); EXPECT(0.5);
3136 CONVERT_STR(VarR8FromStr
,"0.6",LOCALE_NOUSEROVERRIDE
); EXPECT(0.6);
3137 CONVERT_STR(VarR8FromStr
,"1.5",LOCALE_NOUSEROVERRIDE
); EXPECT(1.5);
3139 /* We already have exhaustive tests for number parsing, so skip those tests here */
3142 static void test_VarR8Copy(void)
3144 COPYTEST(77665544.0, VT_R8
, V_R8(&vSrc
), V_R8(&vDst
), V_R8REF(&vSrc
),V_R8REF(&vDst
), "%16.16g");
3147 static void test_VarR8ChangeTypeEx(void)
3149 #ifdef HAS_UINT64_TO_FLOAT
3152 VARIANTARG vSrc
, vDst
;
3156 INITIAL_TYPETEST(VT_R8
, V_R8
, "%g");
3161 #define MATHRND(l, r) left = l; right = r; hres = pVarR8Round(left, right, &out)
3163 static void test_VarR8Round(void)
3166 double left
= 0.0, out
;
3169 CHECKPTR(VarR8Round
);
3170 MATHRND(0.5432, 5); EXPECT(0.5432);
3171 MATHRND(0.5432, 4); EXPECT(0.5432);
3172 MATHRND(0.5432, 3); EXPECT(0.543);
3173 MATHRND(0.5432, 2); EXPECT(0.54);
3174 MATHRND(0.5432, 1); EXPECT(0.5);
3175 MATHRND(0.5532, 0); EXPECT(1);
3176 MATHRND(0.5532, -1); EXPECT_INVALID
;
3178 MATHRND(0.5568, 5); EXPECT(0.5568);
3179 MATHRND(0.5568, 4); EXPECT(0.5568);
3180 MATHRND(0.5568, 3); EXPECT(0.557);
3181 MATHRND(0.5568, 2); EXPECT(0.56);
3182 MATHRND(0.5568, 1); EXPECT(0.6);
3183 MATHRND(0.5568, 0); EXPECT(1);
3184 MATHRND(0.5568, -1); EXPECT_INVALID
;
3186 MATHRND(0.4999, 0); EXPECT(0);
3187 MATHRND(0.5000, 0); EXPECT(0);
3188 MATHRND(0.5001, 0); EXPECT(1);
3189 MATHRND(1.4999, 0); EXPECT(1);
3190 MATHRND(1.5000, 0); EXPECT(2);
3191 MATHRND(1.5001, 0); EXPECT(2);
3199 #define CONV_TYPE DATE
3201 static void test_VarDateFromI1(void)
3203 CONVVARS(signed char);
3206 CHECKPTR(VarDateFromI1
);
3207 CONVERTRANGE(VarDateFromI1
, -128, 128);
3210 static void test_VarDateFromUI1(void)
3215 CHECKPTR(VarDateFromUI1
);
3216 CONVERTRANGE(VarDateFromUI1
, 0, 256);
3219 static void test_VarDateFromI2(void)
3224 CHECKPTR(VarDateFromI2
);
3225 CONVERTRANGE(VarDateFromI2
, -32768, 32768);
3228 static void test_VarDateFromUI2(void)
3233 CHECKPTR(VarDateFromUI2
);
3234 CONVERTRANGE(VarDateFromUI2
, 0, 65536);
3237 static void test_VarDateFromI4(void)
3241 CHECKPTR(VarDateFromI4
);
3242 CONVERT(VarDateFromI4
, DATE_MIN
-1);
3243 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3245 CONVERT(VarDateFromI4
, DATE_MIN
); EXPECT(DATE_MIN
);
3246 CONVERT(VarDateFromI4
, -1); EXPECT(-1.0);
3247 CONVERT(VarDateFromI4
, 0); EXPECT(0.0);
3248 CONVERT(VarDateFromI4
, 1); EXPECT(1.0);
3249 CONVERT(VarDateFromI4
, DATE_MAX
); EXPECT(DATE_MAX
);
3250 CONVERT(VarDateFromI4
, DATE_MAX
+1);
3251 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3255 static void test_VarDateFromUI4(void)
3257 CONVVARS(unsigned int);
3259 CHECKPTR(VarDateFromUI4
);
3260 CONVERT(VarDateFromUI4
, 0); EXPECT(0.0);
3261 CONVERT(VarDateFromUI4
, 1); EXPECT(1.0);
3262 CONVERT(VarDateFromUI4
, DATE_MAX
); EXPECT(DATE_MAX
);
3263 CONVERT(VarDateFromUI4
, DATE_MAX
+1);
3264 if (hres
!= DISP_E_TYPEMISMATCH
) /* Early versions return this, incorrectly */
3268 static void test_VarDateFromR4(void)
3272 CHECKPTR(VarDateFromR4
);
3273 CONVERT(VarDateFromR4
, -1.0f
); EXPECT(-1.0);
3274 CONVERT(VarDateFromR4
, 0.0f
); EXPECT(0.0);
3275 CONVERT(VarDateFromR4
, 1.0f
); EXPECT(1.0);
3276 CONVERT(VarDateFromR4
, 1.5f
); EXPECT(1.5);
3279 static void test_VarDateFromR8(void)
3283 CHECKPTR(VarDateFromR8
);
3284 CONVERT(VarDateFromR8
, -1.0f
); EXPECT(-1.0);
3285 CONVERT(VarDateFromR8
, 0.0f
); EXPECT(0.0);
3286 CONVERT(VarDateFromR8
, 1.0f
); EXPECT(1.0);
3287 CONVERT(VarDateFromR8
, 1.5f
); EXPECT(1.5);
3290 static void test_VarDateFromBool(void)
3292 CONVVARS(VARIANT_BOOL
);
3294 CHECKPTR(VarDateFromBool
);
3295 CONVERT(VarDateFromBool
, VARIANT_TRUE
); EXPECT(VARIANT_TRUE
* 1.0);
3296 CONVERT(VarDateFromBool
, VARIANT_FALSE
); EXPECT(VARIANT_FALSE
* 1.0);
3299 static void test_VarDateFromCy(void)
3303 CHECKPTR(VarDateFromCy
);
3304 CONVERT_CY(VarDateFromCy
,-32769); EXPECT(-32769.0);
3305 CONVERT_CY(VarDateFromCy
,-32768); EXPECT(-32768.0);
3306 CONVERT_CY(VarDateFromCy
,-1); EXPECT(-1.0);
3307 CONVERT_CY(VarDateFromCy
,0); EXPECT(0.0);
3308 CONVERT_CY(VarDateFromCy
,1); EXPECT(1.0);
3309 CONVERT_CY(VarDateFromCy
,32767); EXPECT(32767.0);
3310 CONVERT_CY(VarDateFromCy
,32768); EXPECT(32768.0);
3312 CONVERT_CY(VarDateFromCy
,-1.5); EXPECT(-1.5);
3313 CONVERT_CY(VarDateFromCy
,-0.6); EXPECT(-0.6);
3314 CONVERT_CY(VarDateFromCy
,-0.5); EXPECT(-0.5);
3315 CONVERT_CY(VarDateFromCy
,-0.4); EXPECT(-0.4);
3316 CONVERT_CY(VarDateFromCy
,0.4); EXPECT(0.4);
3317 CONVERT_CY(VarDateFromCy
,0.5); EXPECT(0.5);
3318 CONVERT_CY(VarDateFromCy
,0.6); EXPECT(0.6);
3319 CONVERT_CY(VarDateFromCy
,1.5); EXPECT(1.5);
3322 static void test_VarDateFromI8(void)
3326 CHECKPTR(VarDateFromI8
);
3327 CONVERT(VarDateFromI8
, DATE_MIN
-1); EXPECT_OVERFLOW
;
3328 CONVERT(VarDateFromI8
, DATE_MIN
); EXPECT(DATE_MIN
);
3329 CONVERT(VarDateFromI8
, -1); EXPECT(-1.0);
3330 CONVERT(VarDateFromI8
, 0); EXPECT(0.0);
3331 CONVERT(VarDateFromI8
, 1); EXPECT(1.0);
3332 CONVERT(VarDateFromI8
, DATE_MAX
); EXPECT(DATE_MAX
);
3333 CONVERT(VarDateFromI8
, DATE_MAX
+1); EXPECT_OVERFLOW
;
3336 static void test_VarDateFromUI8(void)
3340 CHECKPTR(VarDateFromUI8
);
3341 CONVERT(VarDateFromUI8
, 0); EXPECT(0.0);
3342 CONVERT(VarDateFromUI8
, 1); EXPECT(1.0);
3343 CONVERT(VarDateFromUI8
, DATE_MAX
); EXPECT(DATE_MAX
);
3344 CONVERT(VarDateFromUI8
, DATE_MAX
+1); EXPECT_OVERFLOW
;
3347 static void test_VarDateFromDec(void)
3351 CHECKPTR(VarDateFromDec
);
3353 CONVERT_BADDEC(VarDateFromDec
);
3355 CONVERT_DEC(VarDateFromDec
,0,0x80,0,32768); EXPECT(-32768.0);
3356 CONVERT_DEC(VarDateFromDec
,0,0x80,0,1); EXPECT(-1.0);
3357 CONVERT_DEC(VarDateFromDec
,0,0,0,0); EXPECT(0.0);
3358 CONVERT_DEC(VarDateFromDec
,0,0,0,1); EXPECT(1.0);
3359 CONVERT_DEC(VarDateFromDec
,0,0,0,32767); EXPECT(32767.0);
3361 CONVERT_DEC(VarDateFromDec
,2,0x80,0,3276800); EXPECT(-32768.0);
3362 CONVERT_DEC(VarDateFromDec
,2,0,0,3276700); EXPECT(32767.0);
3366 buff[0] = '\0'; out = 0.0; \
3367 if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
3368 hres = pVarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
3370 #define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \
3371 pSystemTimeToVariantTime(&st,&relative)
3373 static const char * const BadDateStrings
[] =
3375 "True", "False", /* Plain text */
3376 "0.", ".0", "-1.1", "1.1-", /* Partial specifications */
3377 "1;2;3", "1*2*3", "1@2@3", "1#2#3", "(1:2)","<1:2>","1|2|3", /* Bad chars */
3378 "0", "1", /* 1 element */
3379 "0.60", "24.00", "0:60", "24:00", "1 2 am", "1 am 2", /* 2 elements */
3380 "1.5 2", "1 5.2", "2 32 3", "1 2 am 3", /* 3 elements */
3381 "1 2.3 4", "1.2.3 4", "1 2.3.4", "1.2 3.4", "1.2.3.4", "1 2 3 4",
3382 "1 am 2 3.4", "1 2 am 3.4", "1.2 3 am 4", "1.2 3 4 am", /* 4 elements */
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.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",
3385 "1.2.3 4 am 5", "1.2.3 4 5 am", "1.2 3 am 4 5",
3386 "1.2 3 4 am 5", "1.2 3 4 5 am", "1 am 2 3.4.5", "1 2 am 3.4.5",
3387 "1 am 2 3 4.5", "1 2 am 3 4.5", "1 2 3 am 4.5", /* 5 elements */
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",
3392 "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",
3394 /* following throws an exception on winME */
3395 "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",
3397 "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",
3399 /* following throws an exception on winME */
3400 "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",
3402 "1 2 am 3 4.5.6", "1 2 3 am 4.5.6"
3405 static void test_VarDateFromStr(void)
3414 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3416 CHECKPTR(VarDateFromStr
);
3417 CHECKPTR(SystemTimeToVariantTime
);
3419 /* Some date formats are relative, so we need to find the current year */
3421 st
.wHour
= st
.wMinute
= st
.wSecond
= st
.wMilliseconds
= 0;
3422 DFS(NULL
); EXPECT_MISMATCH
;
3424 /* Floating point number are not recognised */
3427 EXPECT_DBL(0.0); /* Very old versions accept this string */
3431 /* 1 element - can only be a time, and only if it has am/pm */
3432 DFS("1 am"); EXPECT_DBL(0.04166666666666666);
3434 /* A decimal point is treated as a time separator.
3435 * The following are converted as hours/minutes.
3437 DFS("0.1"); EXPECT_DBL(0.0006944444444444445);
3438 DFS("0.40"); EXPECT_DBL(0.02777777777777778);
3439 DFS("2.5"); EXPECT_DBL(0.08680555555555555);
3440 /* A colon acts as a decimal point */
3441 DFS("0:1"); EXPECT_DBL(0.0006944444444444445);
3442 DFS("0:20"); EXPECT_DBL(0.01388888888888889);
3443 DFS("0:40"); EXPECT_DBL(0.02777777777777778);
3444 DFS("3:5"); EXPECT_DBL(0.1284722222222222);
3445 /* Check the am/pm limits */
3446 DFS("00:00 AM"); EXPECT_DBL(0.0);
3447 DFS("00:00 a"); EXPECT_DBL(0.0);
3448 DFS("12:59 AM"); EXPECT_DBL(0.04097222222222222);
3449 DFS("12:59 A"); EXPECT_DBL(0.04097222222222222);
3450 DFS("00:00 pm"); EXPECT_DBL(0.5);
3451 DFS("00:00 p"); EXPECT_DBL(0.5);
3452 DFS("12:59 pm"); EXPECT_DBL(0.5409722222222222);
3453 DFS("12:59 p"); EXPECT_DBL(0.5409722222222222);
3454 /* AM/PM is ignored if hours > 12 */
3455 DFS("13:00 AM"); EXPECT_DBL(0.5416666666666666);
3456 DFS("13:00 PM"); EXPECT_DBL(0.5416666666666666);
3458 /* Space, dash and slash all indicate a date format. */
3459 /* If both numbers are valid month values => month/day of current year */
3460 DFS("1 2"); MKRELDATE(2,1); EXPECT_DBL(relative
);
3461 DFS("2 1"); MKRELDATE(1,2); EXPECT_DBL(relative
);
3462 /* one number not valid month, is a valid day, other number valid month:
3463 * that number becomes the day.
3465 DFS("14 1"); MKRELDATE(14,1); EXPECT_DBL(relative
);
3466 DFS("1 14"); EXPECT_DBL(relative
);
3467 /* If the numbers can't be day/month, they are assumed to be year/month */
3468 DFS("30 2"); EXPECT_DBL(10990.0);
3469 DFS("2 30"); EXPECT_DBL(10990.0);
3470 DFS("32 49"); EXPECT_MISMATCH
; /* Can't be any format */
3471 DFS("0 49"); EXPECT_MISMATCH
; /* Can't be any format */
3472 /* If a month name is given the other number is the day */
3473 DFS("Jan 2"); MKRELDATE(2,1); EXPECT_DBL(relative
);
3474 DFS("2 Jan"); EXPECT_DBL(relative
);
3475 /* Unless it can't be, in which case it becomes the year */
3476 DFS("Jan 35"); EXPECT_DBL(12785.0);
3477 DFS("35 Jan"); EXPECT_DBL(12785.0);
3478 DFS("Jan-35"); EXPECT_DBL(12785.0);
3479 DFS("35-Jan"); EXPECT_DBL(12785.0);
3480 DFS("Jan/35"); EXPECT_DBL(12785.0);
3481 DFS("35/Jan"); EXPECT_DBL(12785.0);
3483 /* 3 numbers and time separator => h:m:s */
3484 DFS("0.1.0"); EXPECT_DBL(0.0006944444444444445);
3485 DFS("1.5.2"); EXPECT_DBL(0.04516203703703704);
3486 /* 3 numbers => picks date giving preference to lcid format */
3487 DFS("1 2 3"); EXPECT_DBL(37623.0);
3488 DFS("14 2 3"); EXPECT_DBL(41673.0);
3489 DFS("2 14 3"); EXPECT_DBL(37666.0);
3490 DFS("2 3 14"); EXPECT_DBL(41673.0);
3491 DFS("32 2 3"); EXPECT_DBL(11722.0);
3492 DFS("2 3 32"); EXPECT_DBL(11722.0);
3493 DFS("1 2 29"); EXPECT_DBL(47120.0);
3494 /* After 30, two digit dates are expected to be in the 1900's */
3495 DFS("1 2 30"); EXPECT_DBL(10960.0);
3496 DFS("1 2 31"); EXPECT_DBL(11325.0);
3497 DFS("3 am 1 2"); MKRELDATE(2,1); relative
+= 0.125; EXPECT_DBL(relative
);
3498 DFS("1 2 3 am"); EXPECT_DBL(relative
);
3500 /* 4 elements -interpreted as 2 digit date & time */
3501 DFS("1.2 3 4"); MKRELDATE(4,3); relative
+= 0.04305555556; EXPECT_DBL(relative
);
3502 DFS("3 4 1.2"); EXPECT_DBL(relative
);
3503 /* 5 elements - interpreted as 2 & 3 digit date/times */
3504 DFS("1.2.3 4 5"); MKRELDATE(5,4); relative
+= 0.04309027778; EXPECT_DBL(relative
);
3505 DFS("1.2 3 4 5"); EXPECT_DBL(38415.04305555556);
3507 /* following throws an exception on winME */
3508 DFS("1 2 3.4.5"); MKRELDATE(2,1); relative
+= 0.12783564815; EXPECT_DBL(relative
);
3510 DFS("1 2 3 4.5"); EXPECT_DBL(37623.17013888889);
3511 /* 6 elements - interpreted as 3 digit date/times */
3512 DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778);
3513 DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
3515 for (i
= 0; i
< sizeof(BadDateStrings
)/sizeof(char*); i
++)
3517 DFS(BadDateStrings
[i
]); EXPECT_MISMATCH
;
3520 /* Some normal-ish strings */
3521 DFS("2 January, 1970"); EXPECT_DBL(25570.0);
3522 DFS("2 January 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("2-Jan-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("1-2-1970"); EXPECT_DBL(25570.0);
3529 DFS("13-1-1970"); EXPECT_DBL(25581.0);
3530 DFS("1970-1-13"); EXPECT_DBL(25581.0);
3531 /* Native fails "1999 January 3, 9AM". I consider that a bug in native */
3533 /* test a non-english data string */
3534 DFS("02.01.1970"); EXPECT_MISMATCH
;
3535 DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH
;
3536 lcid
= MAKELCID(MAKELANGID(LANG_GERMAN
,SUBLANG_GERMAN
),SORT_DEFAULT
);
3537 DFS("02.01.1970"); EXPECT_DBL(25570.0);
3538 DFS("02.13.1970"); EXPECT_DBL(25612.0);
3539 DFS("02-13-1970"); EXPECT_DBL(25612.0);
3540 DFS("2020-01-11"); EXPECT_DBL(43841.0);
3541 DFS("2173-10-14"); EXPECT_DBL(100000.0);
3543 DFS("02.01.1970 00:00:00"); EXPECT_DBL(25570.0);
3544 lcid
= MAKELCID(MAKELANGID(LANG_SPANISH
,SUBLANG_SPANISH
),SORT_DEFAULT
);
3545 DFS("02.01.1970"); EXPECT_MISMATCH
;
3546 DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH
;
3549 static void test_VarDateCopy(void)
3551 COPYTEST(77665544.0, VT_DATE
, V_DATE(&vSrc
), V_DATE(&vDst
), V_DATEREF(&vSrc
),
3552 V_DATEREF(&vDst
), "%16.16g");
3555 static const char* wtoascii(LPWSTR lpszIn
)
3557 static char buff
[256];
3558 WideCharToMultiByte(CP_ACP
, 0, lpszIn
, -1, buff
, sizeof(buff
), NULL
, NULL
);
3562 static void test_VarDateChangeTypeEx(void)
3564 static const WCHAR sz25570
[] = {
3565 '1','/','2','/','1','9','7','0','\0' };
3566 static const WCHAR sz25570_2
[] = {
3567 '1','/','2','/','7','0','\0' };
3568 static const WCHAR sz25570Nls
[] = {
3569 '1','/','2','/','1','9','7','0',' ','1','2',':','0','0',':','0','0',' ','A','M','\0' };
3572 VARIANTARG vSrc
, vDst
;
3577 #ifdef HAS_UINT64_TO_FLOAT
3578 INITIAL_TYPETEST(VT_DATE
, V_DATE
, "%g");
3582 V_VT(&vDst
) = VT_EMPTY
;
3583 V_VT(&vSrc
) = VT_DATE
;
3584 V_DATE(&vSrc
) = 25570.0;
3585 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3587 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, VARIANT_NOUSEROVERRIDE
, VT_BSTR
);
3588 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_BSTR
&& V_BSTR(&vDst
) &&
3589 (!lstrcmpW(V_BSTR(&vDst
), sz25570
) || !lstrcmpW(V_BSTR(&vDst
), sz25570_2
)),
3590 "hres=0x%X, type=%d (should be VT_BSTR), *bstr=%s\n",
3591 hres
, V_VT(&vDst
), V_BSTR(&vDst
) ? wtoascii(V_BSTR(&vDst
)) : "?");
3592 VariantClear(&vDst
);
3594 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
3597 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, VARIANT_NOUSEROVERRIDE
|VARIANT_USE_NLS
, VT_BSTR
);
3598 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_BSTR
&& V_BSTR(&vDst
) && !lstrcmpW(V_BSTR(&vDst
), sz25570Nls
),
3599 "hres=0x%X, type=%d (should be VT_BSTR), *bstr=%s\n",
3600 hres
, V_VT(&vDst
), V_BSTR(&vDst
) ? wtoascii(V_BSTR(&vDst
)) : "?");
3601 VariantClear(&vDst
);
3610 #define CONV_TYPE CY
3612 #define EXPECTCY(x) \
3613 ok((hres == S_OK && out.int64 == (LONGLONG)(x*CY_MULTIPLIER)), \
3614 "expected " #x "*CY_MULTIPLIER, got (%8x %8x); hres=0x%08x\n", S(out).Hi, S(out).Lo, hres)
3616 #define EXPECTCY64(x,y) \
3617 ok(hres == S_OK && S(out).Hi == (LONG)x && S(out).Lo == y, \
3618 "expected " #x " " #y " (%u,%u), got (%u,%u); hres=0x%08x\n", \
3619 (ULONG)(x), (ULONG)(y), S(out).Hi, S(out).Lo, hres)
3621 static void test_VarCyFromI1(void)
3623 CONVVARS(signed char);
3626 CHECKPTR(VarCyFromI1
);
3627 for (i
= -128; i
< 128; i
++)
3629 CONVERT(VarCyFromI1
,i
); EXPECTCY(i
);
3633 static void test_VarCyFromUI1(void)
3638 CHECKPTR(VarCyFromUI1
);
3639 for (i
= 0; i
< 256; i
++)
3641 CONVERT(VarCyFromUI1
,i
); EXPECTCY(i
);
3645 static void test_VarCyFromI2(void)
3650 CHECKPTR(VarCyFromI2
);
3651 for (i
= -16384; i
< 16384; i
++)
3653 CONVERT(VarCyFromI2
,i
); EXPECTCY(i
);
3657 static void test_VarCyFromUI2(void)
3662 CHECKPTR(VarCyFromUI2
);
3663 for (i
= 0; i
< 32768; i
++)
3665 CONVERT(VarCyFromUI2
,i
); EXPECTCY(i
);
3669 static void test_VarCyFromI4(void)
3673 CHECKPTR(VarCyFromI4
);
3674 CONVERT(VarCyFromI4
, -1); EXPECTCY(-1);
3675 CONVERT(VarCyFromI4
, 0); EXPECTCY(0);
3676 CONVERT(VarCyFromI4
, 1); EXPECTCY(1);
3677 CONVERT(VarCyFromI4
, 0x7fffffff); EXPECTCY64(0x1387, 0xffffd8f0);
3678 CONVERT(VarCyFromI4
, 0x80000000); EXPECTCY64(0xffffec78, 0);
3681 static void test_VarCyFromUI4(void)
3683 CONVVARS(unsigned int);
3685 CHECKPTR(VarCyFromUI4
);
3686 CONVERT(VarCyFromUI4
, 0); EXPECTCY(0);
3687 CONVERT(VarCyFromUI4
, 1); EXPECTCY(1);
3688 CONVERT(VarCyFromUI4
, 0x80000000); EXPECTCY64(5000, 0);
3691 static void test_VarCyFromR4(void)
3695 CHECKPTR(VarCyFromR4
);
3696 CONVERT(VarCyFromR4
, -1.0f
); EXPECTCY(-1);
3697 CONVERT(VarCyFromR4
, 0.0f
); EXPECTCY(0);
3698 CONVERT(VarCyFromR4
, 1.0f
); EXPECTCY(1);
3699 CONVERT(VarCyFromR4
, 1.5f
); EXPECTCY(1.5);
3701 CONVERT(VarCyFromR4
, -1.5f
); EXPECTCY(-1.5);
3702 CONVERT(VarCyFromR4
, -0.6f
); EXPECTCY(-0.6);
3703 CONVERT(VarCyFromR4
, -0.5f
); EXPECTCY(-0.5);
3704 CONVERT(VarCyFromR4
, -0.4f
); EXPECTCY(-0.4);
3705 CONVERT(VarCyFromR4
, 0.4f
); EXPECTCY(0.4);
3706 CONVERT(VarCyFromR4
, 0.5f
); EXPECTCY(0.5);
3707 CONVERT(VarCyFromR4
, 0.6f
); EXPECTCY(0.6);
3708 CONVERT(VarCyFromR4
, 1.5f
); EXPECTCY(1.5);
3709 CONVERT(VarCyFromR4
, 1.00009f
); EXPECTCY(1.0001);
3710 CONVERT(VarCyFromR4
, -1.00001f
); EXPECTCY(-1);
3711 CONVERT(VarCyFromR4
, -1.00005f
); EXPECTCY(-1);
3712 CONVERT(VarCyFromR4
, -0.00009f
); EXPECTCY(-0.0001);
3713 CONVERT(VarCyFromR4
, -0.00005f
); EXPECTCY(0);
3714 CONVERT(VarCyFromR4
, -0.00001f
); EXPECTCY(0);
3715 CONVERT(VarCyFromR4
, 0.00001f
); EXPECTCY(0);
3716 CONVERT(VarCyFromR4
, 0.00005f
); EXPECTCY(0);
3717 CONVERT(VarCyFromR4
, 0.00009f
); EXPECTCY(0.0001);
3718 CONVERT(VarCyFromR4
, -1.00001f
); EXPECTCY(-1);
3719 CONVERT(VarCyFromR4
, -1.00005f
); EXPECTCY(-1);
3720 CONVERT(VarCyFromR4
, -1.00009f
); EXPECTCY(-1.0001);
3723 static void test_VarCyFromR8(void)
3727 CHECKPTR(VarCyFromR8
);
3729 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3730 /* Test our rounding is exactly the same. This fails if the special x86
3731 * code is taken out of VarCyFromR8.
3733 CONVERT(VarCyFromR8
, -461168601842738.7904); EXPECTCY64(0xbfffffff, 0xffffff23);
3736 CONVERT(VarCyFromR8
, -4611686018427388416.1); EXPECT_OVERFLOW
;
3737 CONVERT(VarCyFromR8
, -1.0); EXPECTCY(-1);
3738 CONVERT(VarCyFromR8
, -0.0); EXPECTCY(0);
3739 CONVERT(VarCyFromR8
, 1.0); EXPECTCY(1);
3740 CONVERT(VarCyFromR8
, 4611686018427387648.0); EXPECT_OVERFLOW
;
3743 CONVERT(VarCyFromR8
, -1.5f
); EXPECTCY(-1.5);
3744 CONVERT(VarCyFromR8
, -0.6f
); EXPECTCY(-0.6);
3745 CONVERT(VarCyFromR8
, -0.5f
); EXPECTCY(-0.5);
3746 CONVERT(VarCyFromR8
, -0.4f
); EXPECTCY(-0.4);
3747 CONVERT(VarCyFromR8
, 0.4f
); EXPECTCY(0.4);
3748 CONVERT(VarCyFromR8
, 0.5f
); EXPECTCY(0.5);
3749 CONVERT(VarCyFromR8
, 0.6f
); EXPECTCY(0.6);
3750 CONVERT(VarCyFromR8
, 1.5f
); EXPECTCY(1.5);
3751 CONVERT(VarCyFromR8
, 1.00009f
); EXPECTCY(1.0001);
3752 CONVERT(VarCyFromR8
, -1.00001f
); EXPECTCY(-1);
3753 CONVERT(VarCyFromR8
, -1.00005f
); EXPECTCY(-1);
3754 CONVERT(VarCyFromR8
, -0.00009f
); EXPECTCY(-0.0001);
3755 CONVERT(VarCyFromR8
, -0.00005f
); EXPECTCY(0);
3756 CONVERT(VarCyFromR8
, -0.00001f
); EXPECTCY(0);
3757 CONVERT(VarCyFromR8
, 0.00001f
); EXPECTCY(0);
3758 CONVERT(VarCyFromR8
, 0.00005f
); EXPECTCY(0);
3759 CONVERT(VarCyFromR8
, 0.00009f
); EXPECTCY(0.0001);
3760 CONVERT(VarCyFromR8
, -1.00001f
); EXPECTCY(-1);
3761 CONVERT(VarCyFromR8
, -1.00005f
); EXPECTCY(-1);
3762 CONVERT(VarCyFromR8
, -1.00009f
); EXPECTCY(-1.0001);
3765 static void test_VarCyFromBool(void)
3767 CONVVARS(VARIANT_BOOL
);
3770 CHECKPTR(VarCyFromBool
);
3771 for (i
= -32768; i
< 32768; i
++)
3773 CONVERT(VarCyFromBool
, i
); EXPECTCY(i
);
3777 static void test_VarCyFromI8(void)
3781 CHECKPTR(VarCyFromI8
);
3782 CONVERT_I8(VarCyFromI8
, -214749, 2728163227ul); EXPECT_OVERFLOW
;
3783 CONVERT_I8(VarCyFromI8
, -214749, 2728163228ul); EXPECTCY64(2147483648ul,15808);
3784 CONVERT(VarCyFromI8
, -1); EXPECTCY(-1);
3785 CONVERT(VarCyFromI8
, 0); EXPECTCY(0);
3786 CONVERT(VarCyFromI8
, 1); EXPECTCY(1);
3787 CONVERT_I8(VarCyFromI8
, 214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3788 CONVERT_I8(VarCyFromI8
, 214748, 1566804069); EXPECT_OVERFLOW
;
3791 static void test_VarCyFromUI8(void)
3795 CHECKPTR(VarCyFromUI8
);
3796 CONVERT(VarCyFromUI8
, 0); EXPECTCY(0);
3797 CONVERT(VarCyFromUI8
, 1); EXPECTCY(1);
3798 CONVERT_I8(VarCyFromUI8
, 214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3799 CONVERT_I8(VarCyFromUI8
, 214748, 1566804069); EXPECTCY64(2147483647ul, 4294961488ul);
3800 CONVERT_I8(VarCyFromUI8
, 214748, 1566804070); EXPECT_OVERFLOW
;
3801 CONVERT_I8(VarCyFromUI8
, 214749, 1566804068); EXPECT_OVERFLOW
;
3804 static void test_VarCyFromDec(void)
3808 CHECKPTR(VarCyFromDec
);
3810 CONVERT_BADDEC(VarCyFromDec
);
3812 CONVERT_DEC(VarCyFromDec
,0,0x80,0,1); EXPECTCY(-1);
3813 CONVERT_DEC(VarCyFromDec
,0,0,0,0); EXPECTCY(0);
3814 CONVERT_DEC(VarCyFromDec
,0,0,0,1); EXPECTCY(1);
3816 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804068); EXPECTCY64(2147483647ul, 4294951488ul);
3817 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804069); EXPECTCY64(2147483647ul, 4294961488ul);
3818 CONVERT_DEC64(VarCyFromDec
,0,0,0,214748, 1566804070); EXPECT_OVERFLOW
;
3819 CONVERT_DEC64(VarCyFromDec
,0,0,0,214749, 1566804068); EXPECT_OVERFLOW
;
3821 CONVERT_DEC(VarCyFromDec
,2,0,0,100); EXPECTCY(1);
3822 CONVERT_DEC(VarCyFromDec
,2,0x80,0,100); EXPECTCY(-1);
3823 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1); EXPECTCY(-0.01);
3824 CONVERT_DEC(VarCyFromDec
,2,0,0,1); EXPECTCY(0.01);
3825 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1); EXPECTCY(-0.01);
3826 CONVERT_DEC(VarCyFromDec
,2,0,0,999); EXPECTCY(9.99);
3827 CONVERT_DEC(VarCyFromDec
,2,0x80,0,999); EXPECTCY(-9.99);
3828 CONVERT_DEC(VarCyFromDec
,2,0,0,1500); EXPECTCY(15);
3829 CONVERT_DEC(VarCyFromDec
,2,0x80,0,1500); EXPECTCY(-15);
3832 static void test_VarCyFromDate(void)
3836 CHECKPTR(VarCyFromDate
);
3838 #if defined(__i386__) && (defined(_MSC_VER) || defined(__GNUC__))
3839 CONVERT(VarCyFromR8
, -461168601842738.7904); EXPECTCY64(0xbfffffff, 0xffffff23);
3842 CONVERT(VarCyFromDate
, -1.0); EXPECTCY(-1);
3843 CONVERT(VarCyFromDate
, -0.0); EXPECTCY(0);
3844 CONVERT(VarCyFromDate
, 1.0); EXPECTCY(1);
3845 CONVERT(VarCyFromDate
, -4611686018427388416.1); EXPECT_OVERFLOW
;
3846 CONVERT(VarCyFromDate
, 4611686018427387648.0); EXPECT_OVERFLOW
;
3849 CONVERT(VarCyFromDate
, -1.5f
); EXPECTCY(-1.5);
3850 CONVERT(VarCyFromDate
, -0.6f
); EXPECTCY(-0.6);
3851 CONVERT(VarCyFromDate
, -0.5f
); EXPECTCY(-0.5);
3852 CONVERT(VarCyFromDate
, -0.4f
); EXPECTCY(-0.4);
3853 CONVERT(VarCyFromDate
, 0.4f
); EXPECTCY(0.4);
3854 CONVERT(VarCyFromDate
, 0.5f
); EXPECTCY(0.5);
3855 CONVERT(VarCyFromDate
, 0.6f
); EXPECTCY(0.6);
3856 CONVERT(VarCyFromDate
, 1.5f
); EXPECTCY(1.5);
3857 CONVERT(VarCyFromDate
, 1.00009f
); EXPECTCY(1.0001);
3858 CONVERT(VarCyFromDate
, -1.00001f
); EXPECTCY(-1);
3859 CONVERT(VarCyFromDate
, -1.00005f
); EXPECTCY(-1);
3860 CONVERT(VarCyFromDate
, -0.00009f
); EXPECTCY(-0.0001);
3861 CONVERT(VarCyFromDate
, -0.00005f
); EXPECTCY(0);
3862 CONVERT(VarCyFromDate
, -0.00001f
); EXPECTCY(0);
3863 CONVERT(VarCyFromDate
, 0.00001f
); EXPECTCY(0);
3864 CONVERT(VarCyFromDate
, 0.00005f
); EXPECTCY(0);
3865 CONVERT(VarCyFromDate
, 0.00009f
); EXPECTCY(0.0001);
3866 CONVERT(VarCyFromDate
, -1.00001f
); EXPECTCY(-1);
3867 CONVERT(VarCyFromDate
, -1.00005f
); EXPECTCY(-1);
3868 CONVERT(VarCyFromDate
, -1.00009f
); EXPECTCY(-1.0001);
3871 #define MATHVARS1 HRESULT hres; double left = 0.0; CY cyLeft, out
3872 #define MATHVARS2 MATHVARS1; double right = 0.0; CY cyRight
3873 #define MATH1(func, l) left = (double)l; pVarCyFromR8(left, &cyLeft); hres = p##func(cyLeft, &out)
3874 #define MATH2(func, l, r) left = (double)l; right = (double)r; \
3875 pVarCyFromR8(left, &cyLeft); pVarCyFromR8(right, &cyRight); \
3876 hres = p##func(cyLeft, cyRight, &out)
3878 static void test_VarCyAdd(void)
3883 MATH2(VarCyAdd
, 0.5, 0.5); EXPECTCY(1);
3884 MATH2(VarCyAdd
, 0.5, -0.4); EXPECTCY(0.1);
3885 MATH2(VarCyAdd
, 0.5, -0.6); EXPECTCY(-0.1);
3886 MATH2(VarCyAdd
, -0.5, -0.5); EXPECTCY(-1);
3887 MATH2(VarCyAdd
, -922337203685476.0, -922337203685476.0); EXPECT_OVERFLOW
;
3888 MATH2(VarCyAdd
, -922337203685476.0, 922337203685476.0); EXPECTCY(0);
3889 MATH2(VarCyAdd
, 922337203685476.0, -922337203685476.0); EXPECTCY(0);
3890 MATH2(VarCyAdd
, 922337203685476.0, 922337203685476.0); EXPECT_OVERFLOW
;
3893 static void test_VarCyMul(void)
3898 MATH2(VarCyMul
, 534443.0, 0.0); EXPECTCY(0);
3899 MATH2(VarCyMul
, 0.5, 0.5); EXPECTCY(0.25);
3900 MATH2(VarCyMul
, 0.5, -0.4); EXPECTCY(-0.2);
3901 MATH2(VarCyMul
, 0.5, -0.6); EXPECTCY(-0.3);
3902 MATH2(VarCyMul
, -0.5, -0.5); EXPECTCY(0.25);
3903 MATH2(VarCyMul
, 922337203685476.0, 20000); EXPECT_OVERFLOW
;
3906 static void test_VarCySub(void)
3911 MATH2(VarCySub
, 0.5, 0.5); EXPECTCY(0);
3912 MATH2(VarCySub
, 0.5, -0.4); EXPECTCY(0.9);
3913 MATH2(VarCySub
, 0.5, -0.6); EXPECTCY(1.1);
3914 MATH2(VarCySub
, -0.5, -0.5); EXPECTCY(0);
3915 MATH2(VarCySub
, -922337203685476.0, -922337203685476.0); EXPECTCY(0);
3916 MATH2(VarCySub
, -922337203685476.0, 922337203685476.0); EXPECT_OVERFLOW
;
3917 MATH2(VarCySub
, 922337203685476.0, -922337203685476.0); EXPECT_OVERFLOW
;
3918 MATH2(VarCySub
, 922337203685476.0, 922337203685476.0); EXPECTCY(0);
3921 static void test_VarCyAbs(void)
3926 MATH1(VarCyAbs
, 0.5); EXPECTCY(0.5);
3927 MATH1(VarCyAbs
, -0.5); EXPECTCY(0.5);
3928 MATH1(VarCyAbs
, 922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3929 MATH1(VarCyAbs
, -922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3932 static void test_VarCyNeg(void)
3937 MATH1(VarCyNeg
, 0.5); EXPECTCY(-0.5);
3938 MATH1(VarCyNeg
, -0.5); EXPECTCY(0.5);
3939 MATH1(VarCyNeg
, 922337203685476.0); EXPECTCY64(2147483648ul,15808);
3940 MATH1(VarCyNeg
, -922337203685476.0); EXPECTCY64(2147483647ul,4294951488ul);
3943 #define MATHMULI4(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3944 hres = pVarCyMulI4(cyLeft, right, &out)
3946 static void test_VarCyMulI4(void)
3951 CHECKPTR(VarCyMulI4
);
3952 MATHMULI4(534443.0, 0); EXPECTCY(0);
3953 MATHMULI4(0.5, 1); EXPECTCY(0.5);
3954 MATHMULI4(0.5, 2); EXPECTCY(1);
3955 MATHMULI4(922337203685476.0, 1); EXPECTCY64(2147483647ul,4294951488ul);
3956 MATHMULI4(922337203685476.0, 2); EXPECT_OVERFLOW
;
3959 #define MATHMULI8(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3960 hres = pVarCyMulI8(cyLeft, right, &out)
3962 static void test_VarCyMulI8(void)
3967 CHECKPTR(VarCyMulI8
);
3968 MATHMULI8(534443.0, 0); EXPECTCY(0);
3969 MATHMULI8(0.5, 1); EXPECTCY(0.5);
3970 MATHMULI8(0.5, 2); EXPECTCY(1);
3971 MATHMULI8(922337203685476.0, 1); EXPECTCY64(2147483647ul,4294951488ul);
3972 MATHMULI8(922337203685476.0, 2); EXPECT_OVERFLOW
;
3975 #define MATHCMP(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); pVarCyFromR8(right, &cyRight); \
3976 hres = pVarCyCmp(cyLeft, cyRight)
3978 static void test_VarCyCmp(void)
3981 double left
= 0.0, right
= 0.0;
3985 MATHCMP(-1.0, -1.0); EXPECT_EQ
;
3986 MATHCMP(-1.0, 0.0); EXPECT_LT
;
3987 MATHCMP(-1.0, 1.0); EXPECT_LT
;
3988 MATHCMP(-1.0, 2.0); EXPECT_LT
;
3989 MATHCMP(0.0, 1.0); EXPECT_LT
;
3990 MATHCMP(0.0, 0.0); EXPECT_EQ
;
3991 MATHCMP(0.0, -1.0); EXPECT_GT
;
3992 MATHCMP(1.0, -1.0); EXPECT_GT
;
3993 MATHCMP(1.0, 0.0); EXPECT_GT
;
3994 MATHCMP(1.0, 1.0); EXPECT_EQ
;
3995 MATHCMP(1.0, 2.0); EXPECT_LT
;
3998 #define MATHCMPR8(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
3999 hres = pVarCyCmpR8(cyLeft, right);
4001 static void test_VarCyCmpR8(void)
4008 CHECKPTR(VarCyCmpR8
);
4009 MATHCMPR8(-1.0, -1.0); EXPECT_EQ
;
4010 MATHCMPR8(-1.0, 0.0); EXPECT_LT
;
4011 MATHCMPR8(-1.0, 1.0); EXPECT_LT
;
4012 MATHCMPR8(-1.0, 2.0); EXPECT_LT
;
4013 MATHCMPR8(0.0, 1.0); EXPECT_LT
;
4014 MATHCMPR8(0.0, 0.0); EXPECT_EQ
;
4015 MATHCMPR8(0.0, -1.0); EXPECT_GT
;
4016 MATHCMPR8(1.0, -1.0); EXPECT_GT
;
4017 MATHCMPR8(1.0, 0.0); EXPECT_GT
;
4018 MATHCMPR8(1.0, 1.0); EXPECT_EQ
;
4019 MATHCMPR8(1.0, 2.0); EXPECT_LT
;
4023 #define MATHRND(l, r) left = l; right = r; pVarCyFromR8(left, &cyLeft); \
4024 hres = pVarCyRound(cyLeft, right, &out)
4026 static void test_VarCyRound(void)
4031 CHECKPTR(VarCyRound
);
4032 MATHRND(0.5432, 5); EXPECTCY(0.5432);
4033 MATHRND(0.5432, 4); EXPECTCY(0.5432);
4034 MATHRND(0.5432, 3); EXPECTCY(0.543);
4035 MATHRND(0.5432, 2); EXPECTCY(0.54);
4036 MATHRND(0.5432, 1); EXPECTCY(0.5);
4037 MATHRND(0.5532, 0); EXPECTCY(1);
4038 MATHRND(0.5532, -1); EXPECT_INVALID
;
4040 MATHRND(0.5568, 5); EXPECTCY(0.5568);
4041 MATHRND(0.5568, 4); EXPECTCY(0.5568);
4042 MATHRND(0.5568, 3); EXPECTCY(0.557);
4043 MATHRND(0.5568, 2); EXPECTCY(0.56);
4044 MATHRND(0.5568, 1); EXPECTCY(0.6);
4045 MATHRND(0.5568, 0); EXPECTCY(1);
4046 MATHRND(0.5568, -1); EXPECT_INVALID
;
4048 MATHRND(0.4999, 0); EXPECTCY(0);
4049 MATHRND(0.5000, 0); EXPECTCY(0);
4050 MATHRND(0.5001, 0); EXPECTCY(1);
4051 MATHRND(1.4999, 0); EXPECTCY(1);
4052 MATHRND(1.5000, 0); EXPECTCY(2);
4053 MATHRND(1.5001, 0); EXPECTCY(2);
4056 #define MATHFIX(l) left = l; pVarCyFromR8(left, &cyLeft); \
4057 hres = pVarCyFix(cyLeft, &out)
4059 static void test_VarCyFix(void)
4064 MATHFIX(-1.0001); EXPECTCY(-1);
4065 MATHFIX(-1.4999); EXPECTCY(-1);
4066 MATHFIX(-1.5001); EXPECTCY(-1);
4067 MATHFIX(-1.9999); EXPECTCY(-1);
4068 MATHFIX(-0.0001); EXPECTCY(0);
4069 MATHFIX(-0.4999); EXPECTCY(0);
4070 MATHFIX(-0.5001); EXPECTCY(0);
4071 MATHFIX(-0.9999); EXPECTCY(0);
4072 MATHFIX(0.0001); EXPECTCY(0);
4073 MATHFIX(0.4999); EXPECTCY(0);
4074 MATHFIX(0.5001); EXPECTCY(0);
4075 MATHFIX(0.9999); EXPECTCY(0);
4076 MATHFIX(1.0001); EXPECTCY(1);
4077 MATHFIX(1.4999); EXPECTCY(1);
4078 MATHFIX(1.5001); EXPECTCY(1);
4079 MATHFIX(1.9999); EXPECTCY(1);
4082 #define MATHINT(l) left = l; pVarCyFromR8(left, &cyLeft); \
4083 hres = pVarCyInt(cyLeft, &out)
4085 static void test_VarCyInt(void)
4090 MATHINT(-1.0001); EXPECTCY(-2);
4091 MATHINT(-1.4999); EXPECTCY(-2);
4092 MATHINT(-1.5001); EXPECTCY(-2);
4093 MATHINT(-1.9999); EXPECTCY(-2);
4094 MATHINT(-0.0001); EXPECTCY(-1);
4095 MATHINT(-0.4999); EXPECTCY(-1);
4096 MATHINT(-0.5001); EXPECTCY(-1);
4097 MATHINT(-0.9999); EXPECTCY(-1);
4098 MATHINT(0.0001); EXPECTCY(0);
4099 MATHINT(0.4999); EXPECTCY(0);
4100 MATHINT(0.5001); EXPECTCY(0);
4101 MATHINT(0.9999); EXPECTCY(0);
4102 MATHINT(1.0001); EXPECTCY(1);
4103 MATHINT(1.4999); EXPECTCY(1);
4104 MATHINT(1.5001); EXPECTCY(1);
4105 MATHINT(1.9999); EXPECTCY(1);
4113 #define CONV_TYPE DECIMAL
4115 #define EXPECTDEC(scl, sgn, hi, lo) ok(hres == S_OK && \
4116 S(U(out)).scale == (BYTE)(scl) && S(U(out)).sign == (BYTE)(sgn) && \
4117 out.Hi32 == (ULONG)(hi) && U1(out).Lo64 == (ULONG64)(lo), \
4118 "expected (%d,%d,%d,(%x %x)), got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4119 scl, sgn, hi, (LONG)((LONG64)(lo) >> 32), (LONG)((lo) & 0xffffffff), S(U(out)).scale, \
4120 S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4122 #define EXPECTDEC64(scl, sgn, hi, mid, lo) ok(hres == S_OK && \
4123 S(U(out)).scale == (BYTE)(scl) && S(U(out)).sign == (BYTE)(sgn) && \
4124 out.Hi32 == (ULONG)(hi) && S1(U1(out)).Mid32 == (ULONG)(mid) && \
4125 S1(U1(out)).Lo32 == (ULONG)(lo), \
4126 "expected (%d,%d,%d,(%x %x)), got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4127 scl, sgn, hi, (LONG)(mid), (LONG)(lo), S(U(out)).scale, \
4128 S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4130 /* expect either a positive or negative zero */
4131 #define EXPECTDECZERO() ok(hres == S_OK && S(U(out)).scale == 0 && \
4132 (S(U(out)).sign == 0 || S(U(out)).sign == 0x80) && out.Hi32 == 0 && U1(out).Lo64 == 0, \
4133 "expected zero, got (%d,%d,%d,(%x %x)) hres 0x%08x\n", \
4134 S(U(out)).scale, S(U(out)).sign, out.Hi32, S1(U1(out)).Mid32, S1(U1(out)).Lo32, hres)
4136 #define EXPECTDECI if (i < 0) EXPECTDEC(0, 0x80, 0, -i); else EXPECTDEC(0, 0, 0, i)
4138 static void test_VarDecFromI1(void)
4140 CONVVARS(signed char);
4143 CHECKPTR(VarDecFromI1
);
4144 for (i
= -128; i
< 128; i
++)
4146 CONVERT(VarDecFromI1
,i
); EXPECTDECI
;
4150 static void test_VarDecFromI2(void)
4155 CHECKPTR(VarDecFromI2
);
4156 for (i
= -32768; i
< 32768; i
++)
4158 CONVERT(VarDecFromI2
,i
); EXPECTDECI
;
4162 static void test_VarDecFromI4(void)
4167 CHECKPTR(VarDecFromI4
);
4168 for (i
= -32768; i
< 32768; i
++)
4170 CONVERT(VarDecFromI4
,i
); EXPECTDECI
;
4174 static void test_VarDecFromI8(void)
4179 CHECKPTR(VarDecFromI8
);
4180 for (i
= -32768; i
< 32768; i
++)
4182 CONVERT(VarDecFromI8
,i
); EXPECTDECI
;
4186 static void test_VarDecFromUI1(void)
4191 CHECKPTR(VarDecFromUI1
);
4192 for (i
= 0; i
< 256; i
++)
4194 CONVERT(VarDecFromUI1
,i
); EXPECTDECI
;
4198 static void test_VarDecFromUI2(void)
4203 CHECKPTR(VarDecFromUI2
);
4204 for (i
= 0; i
< 65536; i
++)
4206 CONVERT(VarDecFromUI2
,i
); EXPECTDECI
;
4210 static void test_VarDecFromUI4(void)
4215 CHECKPTR(VarDecFromUI4
);
4216 for (i
= 0; i
< 65536; i
++)
4218 CONVERT(VarDecFromUI4
,i
); EXPECTDECI
;
4222 static void test_VarDecFromUI8(void)
4227 CHECKPTR(VarDecFromUI8
);
4228 for (i
= 0; i
< 65536; i
++)
4230 CONVERT(VarDecFromUI8
,i
); EXPECTDECI
;
4234 static void test_VarDecFromBool(void)
4239 CHECKPTR(VarDecFromBool
);
4240 /* Test all possible type values. Note that the result is reduced to 0 or -1 */
4241 for (i
= -32768; i
< 0; i
++)
4243 CONVERT(VarDecFromBool
,i
);
4245 EXPECTDEC(0,0x80,0,1);
4251 static void test_VarDecFromR4(void)
4255 CHECKPTR(VarDecFromR4
);
4257 CONVERT(VarDecFromR4
,-0.6f
); EXPECTDEC(1,0x80,0,6);
4258 CONVERT(VarDecFromR4
,-0.5f
); EXPECTDEC(1,0x80,0,5);
4259 CONVERT(VarDecFromR4
,-0.4f
); EXPECTDEC(1,0x80,0,4);
4260 CONVERT(VarDecFromR4
,0.0f
); EXPECTDEC(0,0,0,0);
4261 CONVERT(VarDecFromR4
,0.4f
); EXPECTDEC(1,0,0,4);
4262 CONVERT(VarDecFromR4
,0.5f
); EXPECTDEC(1,0,0,5);
4263 CONVERT(VarDecFromR4
,0.6f
); EXPECTDEC(1,0,0,6);
4266 static void test_VarDecFromR8(void)
4270 CHECKPTR(VarDecFromR8
);
4272 CONVERT(VarDecFromR8
,-0.6); EXPECTDEC(1,0x80,0,6);
4273 CONVERT(VarDecFromR8
,-0.5); EXPECTDEC(1,0x80,0,5);
4274 CONVERT(VarDecFromR8
,-0.4); EXPECTDEC(1,0x80,0,4);
4275 CONVERT(VarDecFromR8
,0.0); EXPECTDEC(0,0,0,0);
4276 CONVERT(VarDecFromR8
,0.4); EXPECTDEC(1,0,0,4);
4277 CONVERT(VarDecFromR8
,0.5); EXPECTDEC(1,0,0,5);
4278 CONVERT(VarDecFromR8
,0.6); EXPECTDEC(1,0,0,6);
4281 static void test_VarDecFromDate(void)
4285 CHECKPTR(VarDecFromDate
);
4287 CONVERT(VarDecFromDate
,-0.6); EXPECTDEC(1,0x80,0,6);
4288 CONVERT(VarDecFromDate
,-0.5); EXPECTDEC(1,0x80,0,5);
4289 CONVERT(VarDecFromDate
,-0.4); EXPECTDEC(1,0x80,0,4);
4290 CONVERT(VarDecFromDate
,0.0); EXPECTDEC(0,0,0,0);
4291 CONVERT(VarDecFromDate
,0.4); EXPECTDEC(1,0,0,4);
4292 CONVERT(VarDecFromDate
,0.5); EXPECTDEC(1,0,0,5);
4293 CONVERT(VarDecFromDate
,0.6); EXPECTDEC(1,0,0,6);
4296 static void test_VarDecFromStr(void)
4301 CHECKPTR(VarDecFromStr
);
4303 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4305 CONVERT_STR(VarDecFromStr
,NULL
,0); EXPECT_MISMATCH
;
4306 CONVERT_STR(VarDecFromStr
,"-1", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0x80,0,1);
4307 CONVERT_STR(VarDecFromStr
,"0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,0,0);
4308 CONVERT_STR(VarDecFromStr
,"1", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,0,1);
4309 CONVERT_STR(VarDecFromStr
,"0.5", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(1,0,0,5);
4310 CONVERT_STR(VarDecFromStr
,"4294967296", LOCALE_NOUSEROVERRIDE
); EXPECTDEC64(0,0,0,1,0);
4311 CONVERT_STR(VarDecFromStr
,"18446744073709551616", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,1,0);
4312 CONVERT_STR(VarDecFromStr
,"4294967296.0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC64(0,0,0,1,0);
4313 CONVERT_STR(VarDecFromStr
,"18446744073709551616.0", LOCALE_NOUSEROVERRIDE
); EXPECTDEC(0,0,1,0);
4316 static void test_VarDecFromCy(void)
4320 CHECKPTR(VarDecFromCy
);
4322 CONVERT_CY(VarDecFromCy
, -1); EXPECTDEC(4,0x80,0,10000);
4323 CONVERT_CY(VarDecFromCy
, 0); EXPECTDEC(4,0,0,0);
4324 CONVERT_CY(VarDecFromCy
, 1); EXPECTDEC(4,0,0,10000);
4325 CONVERT_CY(VarDecFromCy
, 0.5); EXPECTDEC(4,0,0,5000);
4329 #define MATHVARS1 HRESULT hres; DECIMAL l, out
4331 #define MATHVARS2 MATHVARS1; DECIMAL r
4333 #define MATH1(func) hres = p##func(&l, &out)
4335 #define MATH2(func) hres = p##func(&l, &r, &out)
4337 #define MATH3(func) hres = p##func(&l, r)
4339 static void test_VarDecAbs(void)
4343 CHECKPTR(VarDecAbs
);
4344 SETDEC(l
,0,0x80,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,1);
4345 SETDEC(l
,0,0,0,0); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,0);
4346 SETDEC(l
,0,0x80,0,0); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,0);
4347 SETDEC(l
,0,0,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,0,1);
4349 /* Doesn't check for invalid input */
4350 SETDEC(l
,0,0x7f,0,1); MATH1(VarDecAbs
); EXPECTDEC(0,0x7f,0,1);
4351 SETDEC(l
,0,0x80,29,1); MATH1(VarDecAbs
); EXPECTDEC(0,0,29,1);
4354 static void test_VarDecNeg(void)
4358 CHECKPTR(VarDecNeg
);
4359 SETDEC(l
,0,0x80,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0,0,1);
4360 SETDEC(l
,0,0,0,0); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,0,0); /* '-0'! */
4361 SETDEC(l
,0,0x80,0,0); MATH1(VarDecNeg
); EXPECTDEC(0,0,0,0);
4362 SETDEC(l
,0,0,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,0,1);
4364 /* Doesn't check for invalid input */
4365 SETDEC(l
,0,0x7f,0,1); MATH1(VarDecNeg
); EXPECTDEC(0,0xff,0,1);
4366 SETDEC(l
,0,0x80,29,1); MATH1(VarDecNeg
); EXPECTDEC(0,0,29,1);
4367 SETDEC(l
,0,0,29,1); MATH1(VarDecNeg
); EXPECTDEC(0,0x80,29,1);
4370 static void test_VarDecAdd(void)
4374 CHECKPTR(VarDecAdd
);
4375 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,0);
4376 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4377 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4379 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4380 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,2);
4381 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDECZERO();
4382 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,2); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4384 SETDEC(l
,0,0x80,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4385 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDECZERO();
4386 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0,0,2); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,1);
4387 SETDEC(l
,0,0x80,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,2);
4388 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0x80,0,1);
4390 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,0xfffffffe);
4391 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,(ULONG64
)1 << 32);
4392 SETDEC(l
,0,0,0,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0,(ULONG64
)1 << 32);
4394 SETDEC64(l
,0,0,0,0xffffffff,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC64(0,0,0,0xffffffff,1);
4395 SETDEC64(l
,0,0,0,0xffffffff,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4396 EXPECTDEC64(0,0,0,0xfffffffe,0xffffffff);
4398 SETDEC64(l
,0,0,0,0xffffffff,0xffffffff); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,1,0);
4399 SETDEC64(l
,0,0,0,0xffffffff,0xffffffff); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4400 EXPECTDEC64(0,0,0,0xffffffff,0xfffffffe);
4402 SETDEC(l
,0,0,0xffffffff,0); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(0,0,0xffffffff,1);
4403 SETDEC(l
,0,0,0xffffffff,0); SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4404 EXPECTDEC64(0,0,0xfffffffe,0xffffffff,0xffffffff);
4406 SETDEC64(l
,0,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,0,0x80,0,1); MATH2(VarDecAdd
);
4407 EXPECTDEC64(0,0,0xffffffff,0xffffffff,0xfffffffe);
4408 SETDEC64(l
,0,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
);
4409 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4410 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4412 SETDEC64(l
,1,0,0xffffffff,0xffffffff,0xffffffff);SETDEC(r
,1,0,0,1); MATH2(VarDecAdd
);
4413 todo_wine
EXPECTDEC64(0,0,0x19999999,0x99999999,0x9999999A);
4415 SETDEC64(l
,0,0,0xe22ea493,0xb30310a7,0x70000000);SETDEC64(r
,0,0,0xe22ea493,0xb30310a7,0x70000000); MATH2(VarDecAdd
);
4416 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4417 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4419 SETDEC64(l
,1,0,0xe22ea493,0xb30310a7,0x70000000);SETDEC64(r
,1,0,0xe22ea493,0xb30310a7,0x70000000); MATH2(VarDecAdd
);
4420 todo_wine
EXPECTDEC64(0,0,0x2d3c8750,0xbd670354,0xb0000000);
4422 SETDEC(l
,3,128,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4423 MATH2(VarDecAdd
); EXPECTDEC64(0,0,-1,0xFFFFFFFF,0xFFFFFF84);
4425 SETDEC(l
,3,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4426 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4427 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4429 SETDEC(l
,4,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4430 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4431 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4433 SETDEC(l
,5,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecAdd
);
4434 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4435 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4437 SETDEC(l
,6,0,0,123456); SETDEC64(r
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4438 MATH2(VarDecAdd
); EXPECTDEC64(0,0,-1,0xFFFFFFFF,0xFFFFFFFF);
4440 SETDEC(l
,3,128,0,123456); SETDEC64(r
,0,0,0x19999999,0x99999999,0x99999999);
4441 MATH2(VarDecAdd
); EXPECTDEC64(1,0,-1,0xFFFFFFFF,0xFFFFFB27);
4443 SETDEC(l
,3,128,0,123567); SETDEC64(r
,0,0,0x19999999,0x99999999,0x99999999);
4444 MATH2(VarDecAdd
); EXPECTDEC64(1,0,-1,0xFFFFFFFF,0xFFFFFB26);
4446 /* Promotes to the highest scale, so here the results are in the scale of 2 */
4447 SETDEC(l
,2,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecAdd
); EXPECTDEC(2,0,0,0);
4448 SETDEC(l
,2,0,0,100); SETDEC(r
,0,0,0,1); MATH2(VarDecAdd
); EXPECTDEC(2,0,0,200);
4451 static void test_VarDecSub(void)
4455 CHECKPTR(VarDecSub
);
4456 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecSub
); EXPECTDECZERO();
4457 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecSub
); EXPECTDEC(0,0x80,0,1);
4458 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecSub
); EXPECTDECZERO();
4459 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0x80,0,1); MATH2(VarDecSub
); EXPECTDEC(0,0,0,2);
4462 static void test_VarDecMul(void)
4466 CHECKPTR(VarDecMul
);
4467 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4468 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4469 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0,0);
4470 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0,1);
4471 SETDEC(l
,0,0,0,45000);SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0,0,90000);
4472 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0,0,45000); MATH2(VarDecMul
); EXPECTDEC(0,0,0,90000);
4474 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0x80,0,4);
4475 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0x80,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0x80,0,4);
4476 SETDEC(l
,0,0x80,0,2); SETDEC(r
,0,0x80,0,2); MATH2(VarDecMul
); EXPECTDEC(0,0,0,4);
4478 SETDEC(l
,4,0,0,2); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC(4,0,0,4);
4479 SETDEC(l
,0,0,0,2); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(3,0,0,4);
4480 SETDEC(l
,4,0,0,2); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(7,0,0,4);
4481 /* this last one shows that native oleaut32 does *not* gratuitously seize opportunities
4482 to reduce the scale if possible - the canonical result for the expected value is (6,0,0,1)
4484 SETDEC(l
,4,0,0,5); SETDEC(r
,3,0,0,2); MATH2(VarDecMul
); EXPECTDEC(7,0,0,10);
4486 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC(r
,0,0,0,2); MATH2(VarDecMul
); EXPECTDEC64(0,0,1,0xFFFFFFFF,0xFFFFFFFE);
4487 SETDEC(l
,0,0,0,2); SETDEC64(r
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); MATH2(VarDecMul
); EXPECTDEC64(0,0,1,0xFFFFFFFF,0xFFFFFFFE);
4488 SETDEC(l
,0,0,1,1); SETDEC(r
,0,0,0,0x80000000); MATH2(VarDecMul
); EXPECTDEC(0,0,0x80000000,0x80000000);
4489 SETDEC(l
,0,0,0,0x80000000); SETDEC(r
,0,0,1,1); MATH2(VarDecMul
); EXPECTDEC(0,0,0x80000000,0x80000000);
4491 /* near-overflow, used as a reference */
4492 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC(r
,0,0,0,2000000000); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4493 /* actual overflow - right operand is 10 times the previous value */
4494 SETDEC64(l
,0,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,4,0xA817C800); MATH2(VarDecMul
);
4495 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4496 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4497 /* here, native oleaut32 has an opportunity to avert the overflow, by reducing the scale of the result */
4498 SETDEC64(l
,1,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,4,0xA817C800); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4500 /* near-overflow, used as a reference */
4501 SETDEC64(l
,0,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC(r
,0,0,0,1000000000); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4502 /* actual overflow - right operand is 10 times the previous value */
4503 SETDEC64(l
,0,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC64(r
,0,0,0,2,0x540BE400); MATH2(VarDecMul
);
4504 ok(hres
== DISP_E_OVERFLOW
,"Expected overflow, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4505 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4506 /* here, native oleaut32 has an opportunity to avert the overflow, by reducing the scale of the result */
4507 SETDEC64(l
,1,0,1,0xFFFFFFFF,0xFFFFFFFE); SETDEC64(r
,0,0,0,2,0x540BE400); MATH2(VarDecMul
);EXPECTDEC64(0,0,1999999999,0xFFFFFFFF,0x88CA6C00);
4509 /* this one shows that native oleaut32 is willing to lose significant digits in order to avert an overflow */
4510 SETDEC64(l
,2,0,0,0xFFFFFFFF,0xFFFFFFFF); SETDEC64(r
,0,0,0,9,0x502F9001); MATH2(VarDecMul
);EXPECTDEC64(1,0,0xee6b2800,0x19999998,0xab2e719a);
4513 static void test_VarDecDiv(void)
4517 CHECKPTR(VarDecDiv
);
4518 /* identity divisions */
4519 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,0);
4520 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,1);
4521 SETDEC(l
,1,0,0,1); SETDEC(r
,0,0,0,1); MATH2(VarDecDiv
); EXPECTDEC(1,0,0,1);
4523 /* exact divisions */
4524 SETDEC(l
,0,0,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,5);
4525 SETDEC(l
,1,0,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(1,0,0,5);
4526 SETDEC(l
,0,0,0,45); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,50);
4527 SETDEC(l
,1,0,0,45); SETDEC(r
,2,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,50);
4528 /* these last three results suggest that native oleaut32 scales both operands down to zero
4529 before the division, but does not always try to scale the result, even if it is possible -
4530 analogous to multiplication behavior.
4532 SETDEC(l
,1,0,0,45); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0,0,5);
4533 SETDEC(l
,2,0,0,450); SETDEC(r
,1,0,0,9); MATH2(VarDecDiv
);
4534 if (S(U(out
)).scale
== 1) EXPECTDEC(1,0,0,50);
4535 else EXPECTDEC(0,0,0,5);
4537 /* inexact divisions */
4538 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4539 SETDEC(l
,1,0,0,1); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,18070036,0x35458014,0x4d555555);
4540 SETDEC(l
,0,0,0,1); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,1807003620,0xcf2607ee,0x35555555);
4541 SETDEC(l
,1,0,0,1); SETDEC(r
,2,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,1807003620,0xcf2607ee,0x35555555);
4542 SETDEC(l
,1,0,0,1); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4543 SETDEC(l
,2,0,0,10); SETDEC(r
,1,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,180700362,0x14b700cb,0x05555555);
4545 /* this one shows that native oleaut32 rounds up the result */
4546 SETDEC(l
,0,0,0,2); SETDEC(r
,0,0,0,3); MATH2(VarDecDiv
); EXPECTDEC64(28,0,361400724,0x296e0196,0x0aaaaaab);
4549 SETDEC(l
,0,0x80,0,45); SETDEC(r
,0,0,0,9); MATH2(VarDecDiv
); EXPECTDEC(0,0x80,0,5);
4550 SETDEC(l
,0,0,0,45); SETDEC(r
,0,0x80,0,9); MATH2(VarDecDiv
);EXPECTDEC(0,0x80,0,5);
4551 SETDEC(l
,0,0x80,0,45); SETDEC(r
,0,0x80,0,9); MATH2(VarDecDiv
);EXPECTDEC(0,0,0,5);
4554 SETDEC(l
,0,0,0,0); SETDEC(r
,0,0,0,0); MATH2(VarDecDiv
);/* indeterminate */
4555 ok(hres
== DISP_E_DIVBYZERO
,"Expected division-by-zero, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4556 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4557 SETDEC(l
,0,0,0,1); SETDEC(r
,0,0,0,0); MATH2(VarDecDiv
);/* division by zero */
4558 ok(hres
== DISP_E_DIVBYZERO
,"Expected division-by-zero, got (%d,%d,%d,(%8x,%8x)x) hres 0x%08x\n",
4559 S(U(out
)).scale
, S(U(out
)).sign
, out
.Hi32
, S1(U1(out
)).Mid32
, S1(U1(out
)).Lo32
, hres
);
4563 static void test_VarDecCmp(void)
4567 CHECKPTR(VarDecCmp
);
4569 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4570 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4571 SETDEC(l
,0,0,0,1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4573 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4574 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4575 SETDEC(l
,0,0,0,1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4577 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4578 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4579 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4581 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4582 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4583 SETDEC(l
,0,DECIMAL_NEG
,0,1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4585 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4586 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4587 SETDEC(l
,0,0,0,0); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4589 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4590 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4591 SETDEC(l
,0,0,0,0); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4593 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4594 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4595 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4597 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4598 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4599 SETDEC(l
,0,DECIMAL_NEG
,0,0); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4601 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4602 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4603 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4605 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4606 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4607 SETDEC(l
,0,0,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4609 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4610 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4611 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4613 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4614 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4615 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); SETDEC(out
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4618 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4619 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4620 SETDEC(out
,0,0,0,1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4622 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4623 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4624 SETDEC(out
,0,0,0,1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4626 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4627 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4628 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4630 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_EQ
;
4631 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4632 SETDEC(out
,0,DECIMAL_NEG
,0,1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4634 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4635 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4636 SETDEC(out
,0,0,0,0); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4638 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4639 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4640 SETDEC(out
,0,0,0,0); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4642 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4643 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4644 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4646 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4647 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_EQ
;
4648 SETDEC(out
,0,DECIMAL_NEG
,0,0); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4650 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4651 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4652 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4654 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_LT
;
4655 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_LT
;
4656 SETDEC(out
,0,0,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_LT
;
4658 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4659 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4660 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,0,-1,-1); MATH1(VarDecCmp
); EXPECT_GT
;
4662 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,1); MATH1(VarDecCmp
); EXPECT_GT
;
4663 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,0,0); MATH1(VarDecCmp
); EXPECT_GT
;
4664 SETDEC(out
,0,DECIMAL_NEG
,-1,-1); SETDEC(l
,0,DECIMAL_NEG
,-1,-1); MATH1(VarDecCmp
); EXPECT_EQ
;
4666 SETDEC(l
,3,0,0,123456); SETDEC64(out
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
4667 MATH1(VarDecCmp
); EXPECT_LT
;
4670 static void test_VarDecCmpR8(void)
4676 CHECKPTR(VarDecCmpR8
);
4678 SETDEC(l
,0,0,0,1); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_GT
;
4679 SETDEC(l
,0,0,0,1); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4680 SETDEC(l
,0,0,0,1); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4682 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_LT
;
4683 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4684 SETDEC(l
,0,DECIMAL_NEG
,0,1); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4686 SETDEC(l
,0,0,0,0); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_EQ
;
4687 SETDEC(l
,0,0,0,0); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4688 SETDEC(l
,0,0,0,0); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4690 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= 0.0; MATH3(VarDecCmpR8
); EXPECT_EQ
;
4691 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= 0.1; MATH3(VarDecCmpR8
); EXPECT_LT
;
4692 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= -0.1; MATH3(VarDecCmpR8
); EXPECT_GT
;
4694 SETDEC(l
,0,0,0,1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4695 SETDEC(l
,0,DECIMAL_NEG
,0,0); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4696 SETDEC(l
,0,0,-1,-1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_GT
;
4697 SETDEC(l
,0,DECIMAL_NEG
,-1,-1); r
= DECIMAL_NEG
; MATH3(VarDecCmpR8
); EXPECT_LT
;
4700 #define CLEAR(x) memset(&(x), 0xBB, sizeof(x))
4702 static void test_VarDecRound(void)
4707 CHECKPTR(VarDecRound
);
4709 CLEAR(out
); SETDEC(l
, 0, 0, 0, 1); hres
= pVarDecRound(&l
, 3, &out
); EXPECTDEC(0, 0, 0, 1);
4711 CLEAR(out
); SETDEC(l
, 0, 0, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, 0, 0, 1);
4712 CLEAR(out
); SETDEC(l
, 1, 0, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, 0, 0, 0);
4713 CLEAR(out
); SETDEC(l
, 1, 0, 0, 1); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 1);
4714 CLEAR(out
); SETDEC(l
, 2, 0, 0, 11); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 1);
4715 CLEAR(out
); SETDEC(l
, 2, 0, 0, 15); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 2);
4716 CLEAR(out
); SETDEC(l
, 6, 0, 0, 550001); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 6);
4718 CLEAR(out
); SETDEC(l
, 0, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, DECIMAL_NEG
, 0, 1);
4719 CLEAR(out
); SETDEC(l
, 1, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC(0, DECIMAL_NEG
, 0, 0);
4720 CLEAR(out
); SETDEC(l
, 1, DECIMAL_NEG
, 0, 1); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 1);
4721 CLEAR(out
); SETDEC(l
, 2, DECIMAL_NEG
, 0, 11); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 1);
4722 CLEAR(out
); SETDEC(l
, 2, DECIMAL_NEG
, 0, 15); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 2);
4723 CLEAR(out
); SETDEC(l
, 6, DECIMAL_NEG
, 0, 550001); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, DECIMAL_NEG
, 0, 6);
4725 CLEAR(out
); SETDEC64(l
, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, 0, 0xffffffff, 0xffffffff, 0xffffffff);
4726 CLEAR(out
); SETDEC64(l
, 28, 0, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, 0, 0, 0, 8);
4727 CLEAR(out
); SETDEC64(l
, 0, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff);
4728 CLEAR(out
); SETDEC64(l
, 28, DECIMAL_NEG
, 0xffffffff, 0xffffffff, 0xffffffff); hres
= pVarDecRound(&l
, 0, &out
); EXPECTDEC64(0, DECIMAL_NEG
, 0, 0, 8);
4730 CLEAR(out
); SETDEC(l
, 2, 0, 0, 0); hres
= pVarDecRound(&l
, 1, &out
); EXPECTDEC(1, 0, 0, 0);
4738 #define CONV_TYPE VARIANT_BOOL
4740 #define EXPECTRES(res, x) _EXPECTRES(res, x, "%d")
4742 #define CONVERTRANGE(func,start,end) for (i = start; i < end; i++) { \
4743 CONVERT(func, i); if (i) { EXPECT(VARIANT_TRUE); } else { EXPECT(VARIANT_FALSE); } }
4745 static void test_VarBoolFromI1(void)
4747 CONVVARS(signed char);
4750 CHECKPTR(VarBoolFromI1
);
4751 CONVERTRANGE(VarBoolFromI1
, -128, 128);
4754 static void test_VarBoolFromUI1(void)
4759 CHECKPTR(VarBoolFromUI1
);
4760 CONVERTRANGE(VarBoolFromUI1
, 0, 256);
4763 static void test_VarBoolFromI2(void)
4768 CHECKPTR(VarBoolFromI2
);
4769 CONVERTRANGE(VarBoolFromI2
, -32768, 32768);
4772 static void test_VarBoolFromUI2(void)
4777 CHECKPTR(VarBoolFromUI2
);
4778 CONVERTRANGE(VarBoolFromUI2
, 0, 65536);
4781 static void test_VarBoolFromI4(void)
4785 CHECKPTR(VarBoolFromI4
);
4786 CONVERT(VarBoolFromI4
, 0x80000000); EXPECT(VARIANT_TRUE
);
4787 CONVERT(VarBoolFromI4
, -1); EXPECT(VARIANT_TRUE
);
4788 CONVERT(VarBoolFromI4
, 0); EXPECT(VARIANT_FALSE
);
4789 CONVERT(VarBoolFromI4
, 1); EXPECT(VARIANT_TRUE
);
4790 CONVERT(VarBoolFromI4
, 0x7fffffff); EXPECT(VARIANT_TRUE
);
4793 static void test_VarBoolFromUI4(void)
4797 CHECKPTR(VarBoolFromUI4
);
4798 CONVERT(VarBoolFromI4
, 0); EXPECT(VARIANT_FALSE
);
4799 CONVERT(VarBoolFromI4
, 1); EXPECT(VARIANT_TRUE
);
4800 CONVERT(VarBoolFromI4
, 0x80000000); EXPECT(VARIANT_TRUE
);
4803 static void test_VarBoolFromR4(void)
4807 CHECKPTR(VarBoolFromR4
);
4808 CONVERT(VarBoolFromR4
, -1.0f
); EXPECT(VARIANT_TRUE
);
4809 CONVERT(VarBoolFromR4
, 0.0f
); EXPECT(VARIANT_FALSE
);
4810 CONVERT(VarBoolFromR4
, 1.0f
); EXPECT(VARIANT_TRUE
);
4811 CONVERT(VarBoolFromR4
, 1.5f
); EXPECT(VARIANT_TRUE
);
4814 CONVERT(VarBoolFromR4
, -1.5f
); EXPECT(VARIANT_TRUE
);
4815 CONVERT(VarBoolFromR4
, -0.6f
); EXPECT(VARIANT_TRUE
);
4816 CONVERT(VarBoolFromR4
, -0.5f
); EXPECT(VARIANT_TRUE
);
4817 CONVERT(VarBoolFromR4
, -0.4f
); EXPECT(VARIANT_TRUE
);
4818 CONVERT(VarBoolFromR4
, 0.4f
); EXPECT(VARIANT_TRUE
);
4819 CONVERT(VarBoolFromR4
, 0.5f
); EXPECT(VARIANT_TRUE
);
4820 CONVERT(VarBoolFromR4
, 0.6f
); EXPECT(VARIANT_TRUE
);
4821 CONVERT(VarBoolFromR4
, 1.5f
); EXPECT(VARIANT_TRUE
);
4824 static void test_VarBoolFromR8(void)
4828 /* Hopefully we made the point with R4 above that rounding is
4829 * irrelevant, so we'll skip that for R8 and Date
4831 CHECKPTR(VarBoolFromR8
);
4832 CONVERT(VarBoolFromR8
, -1.0); EXPECT(VARIANT_TRUE
);
4833 CONVERT(VarBoolFromR8
, -0.0); EXPECT(VARIANT_FALSE
);
4834 CONVERT(VarBoolFromR8
, 1.0); EXPECT(VARIANT_TRUE
);
4837 static void test_VarBoolFromCy(void)
4841 CHECKPTR(VarBoolFromCy
);
4842 CONVERT_CY(VarBoolFromCy
, -32769); EXPECT(VARIANT_TRUE
);
4843 CONVERT_CY(VarBoolFromCy
, -32768); EXPECT(VARIANT_TRUE
);
4844 CONVERT_CY(VarBoolFromCy
, -1); EXPECT(VARIANT_TRUE
);
4845 CONVERT_CY(VarBoolFromCy
, 0); EXPECT(VARIANT_FALSE
);
4846 CONVERT_CY(VarBoolFromCy
, 1); EXPECT(VARIANT_TRUE
);
4847 CONVERT_CY(VarBoolFromCy
, 32767); EXPECT(VARIANT_TRUE
);
4848 CONVERT_CY(VarBoolFromCy
, 32768); EXPECT(VARIANT_TRUE
);
4851 static void test_VarBoolFromI8(void)
4855 CHECKPTR(VarBoolFromI8
);
4856 CONVERT(VarBoolFromI8
, -1); EXPECT(VARIANT_TRUE
);
4857 CONVERT(VarBoolFromI8
, 0); EXPECT(VARIANT_FALSE
);
4858 CONVERT(VarBoolFromI8
, 1); EXPECT(VARIANT_TRUE
);
4861 static void test_VarBoolFromUI8(void)
4865 CHECKPTR(VarBoolFromUI8
);
4866 CONVERT(VarBoolFromUI8
, 0); EXPECT(VARIANT_FALSE
);
4867 CONVERT(VarBoolFromUI8
, 1); EXPECT(VARIANT_TRUE
);
4870 static void test_VarBoolFromDec(void)
4874 CHECKPTR(VarBoolFromDec
);
4875 CONVERT_BADDEC(VarBoolFromDec
);
4877 CONVERT_DEC(VarBoolFromDec
,29,0,0,0); EXPECT_INVALID
;
4878 CONVERT_DEC(VarBoolFromDec
,0,0x1,0,0); EXPECT_INVALID
;
4879 CONVERT_DEC(VarBoolFromDec
,0,0x40,0,0); EXPECT_INVALID
;
4880 CONVERT_DEC(VarBoolFromDec
,0,0x7f,0,0); EXPECT_INVALID
;
4882 CONVERT_DEC(VarBoolFromDec
,0,0x80,0,1); EXPECT(VARIANT_TRUE
);
4883 CONVERT_DEC(VarBoolFromDec
,0,0,0,0); EXPECT(VARIANT_FALSE
);
4884 CONVERT_DEC(VarBoolFromDec
,0,0,0,1); EXPECT(VARIANT_TRUE
);
4885 CONVERT_DEC(VarBoolFromDec
,0,0,1,0); EXPECT(VARIANT_TRUE
);
4887 CONVERT_DEC(VarBoolFromDec
,2,0,0,CY_MULTIPLIER
); EXPECT(VARIANT_TRUE
);
4888 CONVERT_DEC(VarBoolFromDec
,2,0x80,0,CY_MULTIPLIER
); EXPECT(VARIANT_TRUE
);
4891 static void test_VarBoolFromDate(void)
4895 CHECKPTR(VarBoolFromDate
);
4896 CONVERT(VarBoolFromDate
, -1.0); EXPECT(VARIANT_TRUE
);
4897 CONVERT(VarBoolFromDate
, -0.0); EXPECT(VARIANT_FALSE
);
4898 CONVERT(VarBoolFromDate
, 1.0); EXPECT(VARIANT_TRUE
);
4901 static void test_VarBoolFromStr(void)
4906 CHECKPTR(VarBoolFromStr
);
4908 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4910 CONVERT_STR(VarBoolFromStr
,NULL
,0);
4911 if (hres
!= E_INVALIDARG
)
4914 /* #FALSE# and #TRUE# Are always accepted */
4915 CONVERT_STR(VarBoolFromStr
,"#FALSE#",0); EXPECT(VARIANT_FALSE
);
4916 CONVERT_STR(VarBoolFromStr
,"#TRUE#",0); EXPECT(VARIANT_TRUE
);
4918 /* Match of #FALSE# and #TRUE# is case sensitive */
4919 CONVERT_STR(VarBoolFromStr
,"#False#",0); EXPECT_MISMATCH
;
4920 /* But match against English is not */
4921 CONVERT_STR(VarBoolFromStr
,"false",0); EXPECT(VARIANT_FALSE
);
4922 CONVERT_STR(VarBoolFromStr
,"False",0); EXPECT(VARIANT_FALSE
);
4923 /* On/Off and yes/no are not acceptable inputs, with any flags set */
4924 CONVERT_STR(VarBoolFromStr
,"On",0xffffffff); EXPECT_MISMATCH
;
4925 CONVERT_STR(VarBoolFromStr
,"Yes",0xffffffff); EXPECT_MISMATCH
;
4927 /* Change the LCID. This doesn't make any difference for text,unless we ask
4928 * to check local boolean text with the VARIANT_LOCALBOOL flag. */
4929 in
= MAKELCID(MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
4931 /* #FALSE# and #TRUE# are accepted in all locales */
4932 CONVERT_STR(VarBoolFromStr
,"#FALSE#",0); EXPECT(VARIANT_FALSE
);
4933 CONVERT_STR(VarBoolFromStr
,"#TRUE#",0); EXPECT(VARIANT_TRUE
);
4934 CONVERT_STR(VarBoolFromStr
,"#FALSE#",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4935 CONVERT_STR(VarBoolFromStr
,"#TRUE#",VARIANT_LOCALBOOL
); EXPECT(VARIANT_TRUE
);
4937 /* English is accepted regardless of the locale */
4938 CONVERT_STR(VarBoolFromStr
,"false",0); EXPECT(VARIANT_FALSE
);
4939 /* And is still not case sensitive */
4940 CONVERT_STR(VarBoolFromStr
,"False",0); EXPECT(VARIANT_FALSE
);
4944 /* French is rejected without VARIANT_LOCALBOOL */
4945 CONVERT_STR(VarBoolFromStr
,"faux",0); EXPECT_MISMATCH
;
4946 /* But accepted if this flag is given */
4947 CONVERT_STR(VarBoolFromStr
,"faux",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4948 /* Regardless of case - from this we assume locale text comparisons ignore case */
4949 CONVERT_STR(VarBoolFromStr
,"Faux",VARIANT_LOCALBOOL
); EXPECT(VARIANT_FALSE
);
4951 /* Changing the locale prevents the localised text from being compared -
4952 * this demonstrates that only the indicated LCID and English are searched */
4953 in
= MAKELCID(MAKELANGID(LANG_POLISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
4954 CONVERT_STR(VarBoolFromStr
,"faux",VARIANT_LOCALBOOL
); EXPECT_MISMATCH
;
4957 /* Numeric strings are read as 0 or non-0 */
4958 CONVERT_STR(VarBoolFromStr
,"0",0); EXPECT(VARIANT_FALSE
);
4959 CONVERT_STR(VarBoolFromStr
,"-1",0); EXPECT(VARIANT_TRUE
);
4960 CONVERT_STR(VarBoolFromStr
,"+1",0); EXPECT(VARIANT_TRUE
);
4964 /* Numeric strings are read as floating point numbers. The line below fails
4965 * because '.' is not a valid decimal separator for Polish numbers */
4966 CONVERT_STR(VarBoolFromStr
,"0.1",LOCALE_NOUSEROVERRIDE
); EXPECT_MISMATCH
;
4969 /* Changing the lcid back to US English reads the r8 correctly */
4970 in
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
4971 CONVERT_STR(VarBoolFromStr
,"0.1",LOCALE_NOUSEROVERRIDE
); EXPECT(VARIANT_TRUE
);
4974 static void test_VarBoolCopy(void)
4976 COPYTEST(1, VT_BOOL
, V_BOOL(&vSrc
), V_BOOL(&vDst
), V_BOOLREF(&vSrc
), V_BOOLREF(&vDst
), "%d");
4979 #define BOOL_STR(flags, str) hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, flags, VT_BSTR); \
4980 ok(hres == S_OK && V_VT(&vDst) == VT_BSTR && \
4981 V_BSTR(&vDst) && !memcmp(V_BSTR(&vDst), str, sizeof(str)), \
4982 "hres=0x%X, type=%d (should be VT_BSTR), *bstr='%c'\n", \
4983 hres, V_VT(&vDst), V_BSTR(&vDst) ? *V_BSTR(&vDst) : '?'); \
4986 static void test_VarBoolChangeTypeEx(void)
4988 static const WCHAR szTrue
[] = { 'T','r','u','e','\0' };
4989 static const WCHAR szFalse
[] = { 'F','a','l','s','e','\0' };
4990 static const WCHAR szFaux
[] = { 'F','a','u','x','\0' };
4993 VARIANTARG vSrc
, vDst
;
4998 INITIAL_TYPETEST(VT_BOOL
, V_BOOL
, "%d");
5001 /* The common tests convert to a number. Try the different flags */
5002 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5004 V_VT(&vSrc
) = VT_BOOL
;
5007 BOOL_STR(VARIANT_ALPHABOOL
, szTrue
);
5009 BOOL_STR(VARIANT_ALPHABOOL
, szFalse
);
5013 lcid
= MAKELCID(MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5015 /* VARIANT_ALPHABOOL is always English */
5016 BOOL_STR(VARIANT_ALPHABOOL
, szFalse
);
5017 /* VARIANT_LOCALBOOL uses the localised text */
5018 BOOL_STR(VARIANT_LOCALBOOL
, szFaux
);
5019 /* Both flags together acts as VARIANT_LOCALBOOL */
5020 BOOL_STR(VARIANT_ALPHABOOL
|VARIANT_LOCALBOOL
, szFaux
);
5028 static void test_VarBstrFromR4(void)
5030 static const WCHAR szNative
[] = { '6','5','4','3','2','2','.','3','\0' };
5031 static const WCHAR szZero
[] = {'0', '\0'};
5032 static const WCHAR szOneHalf_English
[] = { '0','.','5','\0' }; /* uses period */
5033 static const WCHAR szOneHalf_Spanish
[] = { '0',',','5','\0' }; /* uses comma */
5041 CHECKPTR(VarBstrFromR4
);
5043 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5044 lcid_spanish
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH
), SORT_DEFAULT
);
5046 hres
= pVarBstrFromR4(f
, lcid
, 0, &bstr
);
5047 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5051 /* MSDN states that rounding of R4/R8 is dependent on the underlying
5052 * bit pattern of the number and so is architecture dependent. In this
5053 * case Wine returns .2 (which is more correct) and Native returns .3
5055 ok(memcmp(bstr
, szNative
, sizeof(szNative
)) == 0, "string different\n");
5057 SysFreeString(bstr
);
5061 hres
= pVarBstrFromR4(f
, lcid
, 0, &bstr
);
5062 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5066 ok(memcmp(bstr
+ 1, szZero
, sizeof(szZero
)) == 0, "negative zero (got %s)\n", wtoascii(bstr
));
5068 ok(memcmp(bstr
, szZero
, sizeof(szZero
)) == 0, "negative zero (got %s)\n", wtoascii(bstr
));
5069 SysFreeString(bstr
);
5072 /* The following tests that lcid is used for decimal separator even without LOCALE_USE_NLS */
5074 hres
= pVarBstrFromR4(f
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5075 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5078 ok(memcmp(bstr
, szOneHalf_English
, sizeof(szOneHalf_English
)) == 0, "English locale failed (got %s)\n", wtoascii(bstr
));
5079 SysFreeString(bstr
);
5082 hres
= pVarBstrFromR4(f
, lcid_spanish
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5083 ok(hres
== S_OK
, "got hres 0x%08x\n", hres
);
5086 ok(memcmp(bstr
, szOneHalf_Spanish
, sizeof(szOneHalf_Spanish
)) == 0, "Spanish locale failed (got %s)\n", wtoascii(bstr
));
5087 SysFreeString(bstr
);
5091 static void _BSTR_DATE(DATE dt
, const char *str
, int line
)
5093 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5098 hres
= pVarBstrFromDate(dt
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5101 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5102 SysFreeString(bstr
);
5106 ok_(__FILE__
, line
)(hres
== S_OK
&& !strcmp(str
, buff
),
5107 "Expected '%s', got '%s', hres = 0x%08x\n", str
, buff
, hres
);
5110 static void test_VarBstrFromDate(void)
5112 #define BSTR_DATE(dt,str) _BSTR_DATE(dt,str,__LINE__)
5114 CHECKPTR(VarBstrFromDate
);
5116 BSTR_DATE(0.0, "12:00:00 AM");
5117 BSTR_DATE(3.34, "1/2/1900 8:09:36 AM");
5118 BSTR_DATE(3339.34, "2/20/1909 8:09:36 AM");
5119 BSTR_DATE(365.00, "12/30/1900");
5120 BSTR_DATE(365.25, "12/30/1900 6:00:00 AM");
5121 BSTR_DATE(1461.0, "12/31/1903");
5122 BSTR_DATE(1461.5, "12/31/1903 12:00:00 PM");
5123 BSTR_DATE(-49192.24, "4/24/1765 5:45:36 AM");
5124 BSTR_DATE(-657434.0, "1/1/100");
5125 BSTR_DATE(2958465.0, "12/31/9999");
5130 static void _BSTR_CY(LONG a
, LONG b
, const char *str
, LCID lcid
, int line
)
5139 hr
= pVarBstrFromCy(l
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5140 ok(hr
== S_OK
, "got hr 0x%08x\n", hr
);
5144 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5145 SysFreeString(bstr
);
5152 ok_(__FILE__
, line
)(!strcmp(str
, buff
), "Expected '%s', got '%s'\n", str
, buff
);
5156 static void test_VarBstrFromCy(void)
5158 #define BSTR_CY(a, b, str, lcid) _BSTR_CY(a, b, str, lcid, __LINE__)
5162 CHECKPTR(VarBstrFromCy
);
5164 en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5165 sp
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5167 BSTR_CY(0, 0, "0", en_us
);
5168 BSTR_CY(0, 10000, "1", en_us
);
5169 BSTR_CY(0, 15000, "1.5", en_us
);
5170 BSTR_CY(0xffffffff, ((15000)^0xffffffff)+1, "-1.5", en_us
);
5171 /* (1 << 32) - 1 / 1000 */
5172 BSTR_CY(0, 0xffffffff, "429496.7295", en_us
);
5173 /* (1 << 32) / 1000 */
5174 BSTR_CY(1, 0, "429496.7296", en_us
);
5175 /* ((1 << 63) - 1)/10000 */
5176 BSTR_CY(0x7fffffff, 0xffffffff, "922337203685477.5807", en_us
);
5177 BSTR_CY(0, 9, "0.0009", en_us
);
5178 BSTR_CY(0, 9, "0,0009", sp
);
5183 static void _BSTR_DEC(BYTE scale
, BYTE sign
, ULONG hi
, ULONG mid
, ULONGLONG lo
, const char *str
,
5184 LCID lcid
, int line
)
5191 SETDEC64(dec
, scale
, sign
, hi
, mid
, lo
);
5192 hr
= pVarBstrFromDec(&dec
, lcid
, LOCALE_NOUSEROVERRIDE
, &bstr
);
5193 ok_(__FILE__
, line
)(hr
== S_OK
, "got hr 0x%08x\n", hr
);
5197 WideCharToMultiByte(CP_ACP
, 0, bstr
, -1, buff
, sizeof(buff
), 0, 0);
5198 SysFreeString(bstr
);
5205 ok_(__FILE__
, line
)(!strcmp(str
, buff
), "Expected '%s', got '%s'\n", str
, buff
);
5209 static void test_VarBstrFromDec(void)
5211 #define BSTR_DEC(scale, sign, hi, lo, str, lcid) _BSTR_DEC(scale, sign, hi, 0, lo, str, lcid, __LINE__)
5212 #define BSTR_DEC64(scale, sign, hi, mid, lo, str, lcid) _BSTR_DEC(scale, sign, hi, mid, lo, str, lcid, __LINE__)
5216 CHECKPTR(VarBstrFromDec
);
5218 en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5219 sp
= MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
);
5221 BSTR_DEC(0,0,0,0, "0", en_us
);
5223 BSTR_DEC(0,0,0,1, "1", en_us
);
5224 BSTR_DEC(1,0,0,10, "1", en_us
);
5225 BSTR_DEC(2,0,0,100, "1", en_us
);
5226 BSTR_DEC(3,0,0,1000,"1", en_us
);
5228 BSTR_DEC(1,0,0,15, "1.5", en_us
);
5229 BSTR_DEC(2,0,0,150, "1.5", en_us
);
5230 BSTR_DEC(3,0,0,1500,"1.5", en_us
);
5232 BSTR_DEC(1,0x80,0,15, "-1.5", en_us
);
5235 BSTR_DEC(0,0,0,0xffffffff, "4294967295", en_us
);
5237 BSTR_DEC64(0,0,0,1,0, "4294967296", en_us
);
5239 BSTR_DEC64(0,0,0,0xffffffff,0xffffffff, "18446744073709551615", en_us
);
5241 BSTR_DEC(0,0,1,0, "18446744073709551616", en_us
);
5243 BSTR_DEC64(0,0,0xffffffff,0xffffffff,0xffffffff, "79228162514264337593543950335", en_us
);
5245 BSTR_DEC(10,0,0,1, "0.0000000001", en_us
);
5246 /* ((1 << 96) - 1) * 10^-10 */
5247 BSTR_DEC64(10,0,0xffffffffUL
,0xffffffff,0xffffffff, "7922816251426433759.3543950335", en_us
);
5248 /* ((1 << 96) - 1) * 10^-28 */
5249 BSTR_DEC64(28,0,0xffffffffUL
,0xffffffff,0xffffffff, "7.9228162514264337593543950335", en_us
);
5251 /* check leading zeros and decimal sep. for English locale */
5252 BSTR_DEC(4,0,0,9, "0.0009", en_us
);
5253 BSTR_DEC(5,0,0,90, "0.0009", en_us
);
5254 BSTR_DEC(6,0,0,900, "0.0009", en_us
);
5255 BSTR_DEC(7,0,0,9000, "0.0009", en_us
);
5257 /* check leading zeros and decimal sep. for Spanish locale */
5258 BSTR_DEC(4,0,0,9, "0,0009", sp
);
5259 BSTR_DEC(5,0,0,90, "0,0009", sp
);
5260 BSTR_DEC(6,0,0,900, "0,0009", sp
);
5261 BSTR_DEC(7,0,0,9000, "0,0009", sp
);
5267 #define _VARBSTRCMP(left,right,lcid,flags,result) \
5268 hres = pVarBstrCmp(left,right,lcid,flags); \
5269 ok(hres == result, "VarBstrCmp: expected " #result ", got hres=0x%x\n", hres)
5270 #define VARBSTRCMP(left,right,flags,result) \
5271 _VARBSTRCMP(left,right,lcid,flags,result)
5273 static void test_VarBstrCmp(void)
5277 static const WCHAR sz
[] = {'W','u','r','s','c','h','t','\0'};
5278 static const WCHAR szempty
[] = {'\0'};
5279 static const WCHAR sz1
[] = { 'a',0 };
5280 static const WCHAR sz2
[] = { 'A',0 };
5281 static const WCHAR s1
[] = { 'a',0 };
5282 static const WCHAR s2
[] = { 'a',0,'b' };
5283 static const char sb1
[] = {1,0,1};
5284 static const char sb2
[] = {1,0,2};
5285 static const char sbchr0
[] = {0,0};
5286 static const char sbchr00
[] = {0,0,0};
5287 BSTR bstr
, bstrempty
, bstr2
;
5289 CHECKPTR(VarBstrCmp
);
5291 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
5292 bstr
= SysAllocString(sz
);
5293 bstrempty
= SysAllocString(szempty
);
5295 /* NULL handling. Yepp, MSDN is totally wrong here */
5296 VARBSTRCMP(NULL
,NULL
,0,VARCMP_EQ
);
5297 VARBSTRCMP(bstr
,NULL
,0,VARCMP_GT
);
5298 VARBSTRCMP(NULL
,bstr
,0,VARCMP_LT
);
5300 /* NULL and empty string comparisons */
5301 VARBSTRCMP(bstrempty
,NULL
,0,VARCMP_EQ
);
5302 VARBSTRCMP(NULL
,bstrempty
,0,VARCMP_EQ
);
5304 SysFreeString(bstr
);
5305 bstr
= SysAllocString(sz1
);
5307 bstr2
= SysAllocString(sz2
);
5308 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5309 VARBSTRCMP(bstr
,bstr2
,NORM_IGNORECASE
,VARCMP_EQ
);
5310 SysFreeString(bstr2
);
5311 /* These two strings are considered equal even though one is
5312 * NULL-terminated and the other not.
5314 bstr2
= SysAllocStringLen(s1
, sizeof(s1
) / sizeof(WCHAR
));
5315 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_EQ
);
5316 SysFreeString(bstr2
);
5318 /* These two strings are not equal */
5319 bstr2
= SysAllocStringLen(s2
, sizeof(s2
) / sizeof(WCHAR
));
5320 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5321 SysFreeString(bstr2
);
5323 SysFreeString(bstr
);
5325 bstr
= SysAllocStringByteLen(sbchr0
, sizeof(sbchr0
));
5326 bstr2
= SysAllocStringByteLen(sbchr00
, sizeof(sbchr00
));
5327 VARBSTRCMP(bstr
,bstrempty
,0,VARCMP_GT
);
5328 VARBSTRCMP(bstrempty
,bstr
,0,VARCMP_LT
);
5329 VARBSTRCMP(bstr2
,bstrempty
,0,VARCMP_GT
);
5330 VARBSTRCMP(bstr2
,bstr
,0,VARCMP_EQ
);
5331 SysFreeString(bstr2
);
5332 SysFreeString(bstr
);
5334 /* When (LCID == 0) it should be a binary comparison
5335 * so these two strings could not match.
5337 bstr
= SysAllocStringByteLen(sb1
, sizeof(sb1
));
5338 bstr2
= SysAllocStringByteLen(sb2
, sizeof(sb2
));
5340 VARBSTRCMP(bstr
,bstr2
,0,VARCMP_LT
);
5341 SysFreeString(bstr2
);
5342 SysFreeString(bstr
);
5344 bstr
= SysAllocStringByteLen(sbchr0
, sizeof(sbchr0
));
5345 bstr2
= SysAllocStringByteLen(sbchr00
, sizeof(sbchr00
));
5346 VARBSTRCMP(bstr
,bstrempty
,0,VARCMP_GT
);
5347 VARBSTRCMP(bstrempty
,bstr
,0,VARCMP_LT
);
5348 VARBSTRCMP(bstr2
,bstrempty
,0,VARCMP_GT
);
5349 VARBSTRCMP(bstr2
,bstr
,0,VARCMP_GT
);
5350 SysFreeString(bstr2
);
5351 SysFreeString(bstr
);
5352 SysFreeString(bstrempty
);
5355 /* Get the internal representation of a BSTR */
5356 static inline LPINTERNAL_BSTR
Get(const BSTR lpszString
)
5358 return lpszString
? (LPINTERNAL_BSTR
)((char*)lpszString
- sizeof(DWORD
)) : NULL
;
5361 static inline BSTR
GetBSTR(const LPINTERNAL_BSTR bstr
)
5363 return (BSTR
)bstr
->szString
;
5366 static void test_SysStringLen(void)
5369 BSTR str
= GetBSTR(&bstr
);
5372 ok (SysStringLen(str
) == 0, "Expected dwLen 0, got %d\n", SysStringLen(str
));
5374 ok (SysStringLen(str
) == 1, "Expected dwLen 1, got %d\n", SysStringLen(str
));
5377 static void test_SysStringByteLen(void)
5380 BSTR str
= GetBSTR(&bstr
);
5383 ok (SysStringByteLen(str
) == 0, "Expected dwLen 0, got %d\n", SysStringByteLen(str
));
5385 ok (SysStringByteLen(str
) == 2, "Expected dwLen 2, got %d\n", SysStringByteLen(str
));
5388 static void test_SysAllocString(void)
5390 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5393 str
= SysAllocString(NULL
);
5394 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5396 str
= SysAllocString(szTest
);
5397 ok (str
!= NULL
, "Expected non-NULL\n");
5400 LPINTERNAL_BSTR bstr
= Get(str
);
5401 DWORD_PTR p
= (DWORD_PTR
)str
;
5402 int align
= sizeof(void *);
5404 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5405 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5406 ok ((p
& ~(align
-1)) == p
, "Not aligned to %d\n", align
);
5411 static void test_SysAllocStringLen(void)
5413 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5416 /* Very early native dlls do not limit the size of strings, so skip this test */
5419 str
= SysAllocStringLen(szTest
, 0x80000000);
5420 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5423 str
= SysAllocStringLen(NULL
, 0);
5424 ok (str
!= NULL
, "Expected non-NULL\n");
5427 LPINTERNAL_BSTR bstr
= Get(str
);
5429 ok (bstr
->dwLen
== 0, "Expected 0, got %d\n", bstr
->dwLen
);
5430 ok (!bstr
->szString
[0], "String not empty\n");
5434 str
= SysAllocStringLen(szTest
, 4);
5435 ok (str
!= NULL
, "Expected non-NULL\n");
5438 LPINTERNAL_BSTR bstr
= Get(str
);
5440 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5441 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5446 static void test_SysAllocStringByteLen(void)
5448 const OLECHAR szTest
[10] = { 'T','e','s','t','\0' };
5449 const CHAR szTestA
[6] = { 'T','e','s','t','\0','?' };
5454 if (sizeof(void *) == 4) /* not limited to 0x80000000 on Win64 */
5456 str
= SysAllocStringByteLen(szTestA
, 0x80000000);
5457 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5460 str
= SysAllocStringByteLen(szTestA
, 0xffffffff);
5461 ok (str
== NULL
, "Expected NULL, got %p\n", str
);
5463 str
= SysAllocStringByteLen(NULL
, 0);
5464 ok (str
!= NULL
, "Expected non-NULL\n");
5467 LPINTERNAL_BSTR bstr
= Get(str
);
5469 ok (bstr
->dwLen
== 0, "Expected 0, got %d\n", bstr
->dwLen
);
5470 ok (!bstr
->szString
[0], "String not empty\n");
5474 str
= SysAllocStringByteLen(szTestA
, 4);
5475 ok (str
!= NULL
, "Expected non-NULL\n");
5478 LPINTERNAL_BSTR bstr
= Get(str
);
5480 ok (bstr
->dwLen
== 4, "Expected 4, got %d\n", bstr
->dwLen
);
5481 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestA
), "String different\n");
5485 /* Odd lengths are allocated rounded up, but truncated at the right position */
5486 str
= SysAllocStringByteLen(szTestA
, 3);
5487 ok (str
!= NULL
, "Expected non-NULL\n");
5490 const CHAR szTestTruncA
[4] = { 'T','e','s','\0' };
5491 LPINTERNAL_BSTR bstr
= Get(str
);
5493 ok (bstr
->dwLen
== 3, "Expected 3, got %d\n", bstr
->dwLen
);
5494 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestTruncA
), "String different\n");
5495 ok (!bstr
->szString
[2], "String not terminated\n");
5499 str
= SysAllocStringByteLen((LPCSTR
)szTest
, 8);
5500 ok (str
!= NULL
, "Expected non-NULL\n");
5503 LPINTERNAL_BSTR bstr
= Get(str
);
5505 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5506 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5510 /* Make sure terminating null is aligned properly */
5511 buf
= HeapAlloc(GetProcessHeap(), 0, 1025);
5512 ok (buf
!= NULL
, "Expected non-NULL\n");
5513 for (i
= 0; i
< 1024; i
++)
5515 LPINTERNAL_BSTR bstr
;
5517 str
= SysAllocStringByteLen(NULL
, i
);
5518 ok (str
!= NULL
, "Expected non-NULL\n");
5520 ok (bstr
->dwLen
== i
, "Expected %d, got %d\n", i
, bstr
->dwLen
);
5521 ok (!bstr
->szString
[(i
+sizeof(WCHAR
)-1)/sizeof(WCHAR
)], "String not terminated\n");
5524 memset(buf
, 0xaa, 1025);
5525 str
= SysAllocStringByteLen(buf
, i
);
5526 ok (str
!= NULL
, "Expected non-NULL\n");
5528 ok (bstr
->dwLen
== i
, "Expected %d, got %d\n", i
, bstr
->dwLen
);
5530 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, buf
), "String different\n");
5531 ok (!bstr
->szString
[(i
+sizeof(WCHAR
)-1)/sizeof(WCHAR
)], "String not terminated\n");
5534 HeapFree(GetProcessHeap(), 0, buf
);
5537 static void test_SysReAllocString(void)
5539 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5540 const OLECHAR szSmaller
[2] = { 'x','\0' };
5541 const OLECHAR szLarger
[7] = { 'L','a','r','g','e','r','\0' };
5544 str
= SysAllocStringLen(szTest
, 4);
5545 ok (str
!= NULL
, "Expected non-NULL\n");
5548 LPINTERNAL_BSTR bstr
;
5552 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5553 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5555 changed
= SysReAllocString(&str
, szSmaller
);
5556 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5557 /* Vista creates a new string, but older versions reuse the existing string. */
5558 /*ok (str == oldstr, "Created new string\n");*/
5560 ok (bstr
->dwLen
== 2, "Expected 2, got %d\n", bstr
->dwLen
);
5561 ok (!lstrcmpW(bstr
->szString
, szSmaller
), "String different\n");
5563 changed
= SysReAllocString(&str
, szLarger
);
5564 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5565 /* Early versions always make new strings rather than resizing */
5566 /* ok (str == oldstr, "Created new string\n"); */
5568 ok (bstr
->dwLen
== 12, "Expected 12, got %d\n", bstr
->dwLen
);
5569 ok (!lstrcmpW(bstr
->szString
, szLarger
), "String different\n");
5575 static void test_SysReAllocStringLen(void)
5577 const OLECHAR szTest
[5] = { 'T','e','s','t','\0' };
5578 const OLECHAR szSmaller
[2] = { 'x','\0' };
5579 const OLECHAR szLarger
[7] = { 'L','a','r','g','e','r','\0' };
5582 str
= SysAllocStringLen(szTest
, 4);
5583 ok (str
!= NULL
, "Expected non-NULL\n");
5586 LPINTERNAL_BSTR bstr
;
5590 ok (bstr
->dwLen
== 8, "Expected 8, got %d\n", bstr
->dwLen
);
5591 ok (!lstrcmpW(bstr
->szString
, szTest
), "String different\n");
5593 changed
= SysReAllocStringLen(&str
, szSmaller
, 1);
5594 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5595 /* Vista creates a new string, but older versions reuse the existing string. */
5596 /*ok (str == oldstr, "Created new string\n");*/
5598 ok (bstr
->dwLen
== 2, "Expected 2, got %d\n", bstr
->dwLen
);
5599 ok (!lstrcmpW(bstr
->szString
, szSmaller
), "String different\n");
5601 changed
= SysReAllocStringLen(&str
, szLarger
, 6);
5602 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5603 /* Early versions always make new strings rather than resizing */
5604 /* ok (str == oldstr, "Created new string\n"); */
5606 ok (bstr
->dwLen
== 12, "Expected 12, got %d\n", bstr
->dwLen
);
5607 ok (!lstrcmpW(bstr
->szString
, szLarger
), "String different\n");
5609 changed
= SysReAllocStringLen(&str
, str
, 6);
5610 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5615 /* Windows always returns null terminated strings */
5616 str
= SysAllocStringLen(szTest
, 4);
5617 ok (str
!= NULL
, "Expected non-NULL\n");
5620 const int CHUNK_SIZE
= 64;
5621 const int STRING_SIZE
= 24;
5623 changed
= SysReAllocStringLen(&str
, NULL
, CHUNK_SIZE
);
5624 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5625 ok (str
!= NULL
, "Expected non-NULL\n");
5630 /* Filling string */
5631 memset (str
, 0xAB, CHUNK_SIZE
* sizeof (OLECHAR
));
5632 /* Checking null terminator */
5633 changed
= SysReAllocStringLen(&str
, NULL
, STRING_SIZE
);
5634 ok (changed
== 1, "Expected 1, got %d\n", changed
);
5635 ok (str
!= NULL
, "Expected non-NULL\n");
5638 ok (str
== oldstr
, "Expected reuse of the old string memory\n");
5639 ok (str
[STRING_SIZE
] == 0,
5640 "Expected null terminator, got 0x%04X\n", str
[STRING_SIZE
]);
5646 /* Some Windows applications use the same pointer for pbstr and psz */
5647 str
= SysAllocStringLen(szTest
, 4);
5648 ok(str
!= NULL
, "Expected non-NULL\n");
5651 SysReAllocStringLen(&str
, str
, 1000000);
5652 ok(SysStringLen(str
)==1000000, "Incorrect string length\n");
5653 ok(!memcmp(szTest
, str
, 4*sizeof(WCHAR
)), "Incorrect string returned\n");
5659 static void test_BstrCopy(void)
5661 const CHAR szTestA
[6] = { 'T','e','s','t','\0','?' };
5662 const CHAR szTestTruncA
[4] = { 'T','e','s','\0' };
5663 LPINTERNAL_BSTR bstr
;
5668 str
= SysAllocStringByteLen(szTestA
, 3);
5669 ok (str
!= NULL
, "Expected non-NULL\n");
5672 V_VT(&vt1
) = VT_BSTR
;
5674 V_VT(&vt2
) = VT_EMPTY
;
5675 hres
= VariantCopy(&vt2
, &vt1
);
5676 ok (hres
== S_OK
,"Failed to copy binary bstring with hres 0x%08x\n", hres
);
5677 bstr
= Get(V_BSTR(&vt2
));
5678 ok (bstr
->dwLen
== 3, "Expected 3, got %d\n", bstr
->dwLen
);
5679 ok (!lstrcmpA((LPCSTR
)bstr
->szString
, szTestTruncA
), "String different\n");
5685 static void test_VarBstrCat(void)
5687 static const WCHAR sz1
[] = { 'a',0 };
5688 static const WCHAR sz2
[] = { 'b',0 };
5689 static const WCHAR sz1sz2
[] = { 'a','b',0 };
5690 static const WCHAR s1
[] = { 'a',0 };
5691 static const WCHAR s2
[] = { 'b',0 };
5692 static const WCHAR s1s2
[] = { 'a',0,'b',0 };
5693 static const char str1A
[] = "Have ";
5694 static const char str2A
[] = "A Cigar";
5696 BSTR str1
, str2
, res
;
5699 CHECKPTR(VarBstrCat
);
5704 pVarBstrCat(NULL
, NULL
, NULL
);
5707 /* Concatenation of two NULL strings works */
5708 ret
= pVarBstrCat(NULL
, NULL
, &res
);
5709 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5710 ok(res
!= NULL
, "Expected a string\n");
5711 ok(SysStringLen(res
) == 0, "Expected a 0-length string\n");
5714 str1
= SysAllocString(sz1
);
5716 /* Concatenation with one NULL arg */
5717 ret
= pVarBstrCat(NULL
, str1
, &res
);
5718 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5719 ok(res
!= NULL
, "Expected a string\n");
5720 ok(SysStringLen(res
) == SysStringLen(str1
), "Unexpected length\n");
5721 ok(!memcmp(res
, sz1
, SysStringLen(str1
)), "Unexpected value\n");
5723 ret
= pVarBstrCat(str1
, NULL
, &res
);
5724 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5725 ok(res
!= NULL
, "Expected a string\n");
5726 ok(SysStringLen(res
) == SysStringLen(str1
), "Unexpected length\n");
5727 ok(!memcmp(res
, sz1
, SysStringLen(str1
)), "Unexpected value\n");
5730 /* Concatenation of two zero-terminated strings */
5731 str2
= SysAllocString(sz2
);
5732 ret
= pVarBstrCat(str1
, str2
, &res
);
5733 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5734 ok(res
!= NULL
, "Expected a string\n");
5735 ok(SysStringLen(res
) == sizeof(sz1sz2
) / sizeof(WCHAR
) - 1,
5736 "Unexpected length\n");
5737 ok(!memcmp(res
, sz1sz2
, sizeof(sz1sz2
)), "Unexpected value\n");
5740 SysFreeString(str2
);
5741 SysFreeString(str1
);
5743 /* Concatenation of two strings with embedded NULLs */
5744 str1
= SysAllocStringLen(s1
, sizeof(s1
) / sizeof(WCHAR
));
5745 str2
= SysAllocStringLen(s2
, sizeof(s2
) / sizeof(WCHAR
));
5747 ret
= pVarBstrCat(str1
, str2
, &res
);
5748 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5749 ok(res
!= NULL
, "Expected a string\n");
5750 ok(SysStringLen(res
) == sizeof(s1s2
) / sizeof(WCHAR
),
5751 "Unexpected length\n");
5752 ok(!memcmp(res
, s1s2
, sizeof(s1s2
)), "Unexpected value\n");
5755 SysFreeString(str2
);
5756 SysFreeString(str1
);
5758 /* Concatenation of ansi BSTRs, both odd byte count not including termination */
5759 str1
= SysAllocStringByteLen(str1A
, sizeof(str1A
)-1);
5760 str2
= SysAllocStringByteLen(str2A
, sizeof(str2A
)-1);
5761 len
= SysStringLen(str1
);
5762 ok(len
== (sizeof(str1A
)-1)/sizeof(WCHAR
), "got length %u\n", len
);
5763 len
= SysStringLen(str2
);
5764 ok(len
== (sizeof(str2A
)-1)/sizeof(WCHAR
), "got length %u\n", len
);
5766 ret
= pVarBstrCat(str1
, str2
, &res
);
5767 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5768 ok(res
!= NULL
, "Expected a string\n");
5769 len
= (sizeof(str1A
) + sizeof(str2A
) - 2)/sizeof(WCHAR
);
5770 ok(SysStringLen(res
) == len
, "got %d, expected %u\n", SysStringLen(res
), len
);
5771 ok(!memcmp(res
, "Have A Cigar", sizeof(str1A
) + sizeof(str2A
) - 1), "got (%s)\n", (char*)res
);
5774 SysFreeString(str2
);
5775 SysFreeString(str1
);
5777 /* Concatenation of ansi BSTRs, both 1 byte length not including termination */
5778 str1
= SysAllocStringByteLen(str1A
, 1);
5779 str2
= SysAllocStringByteLen(str2A
, 1);
5780 len
= SysStringLen(str1
);
5781 ok(len
== 0, "got length %u\n", len
);
5782 len
= SysStringLen(str2
);
5783 ok(len
== 0, "got length %u\n", len
);
5785 ret
= pVarBstrCat(str1
, str2
, &res
);
5786 ok(ret
== S_OK
, "VarBstrCat failed: %08x\n", ret
);
5787 ok(res
!= NULL
, "Expected a string\n");
5788 ok(SysStringLen(res
) == 1, "got %d, expected 1\n", SysStringLen(res
));
5789 ok(!memcmp(res
, "HA", 2), "got (%s)\n", (char*)res
);
5792 SysFreeString(str2
);
5793 SysFreeString(str1
);
5798 static void test_IUnknownClear(void)
5805 init_test_dispatch(1, VT_UI1
, &u
);
5806 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5808 /* Test that IUnknown_Release is called on by-value */
5809 V_VT(&v
) = VT_UNKNOWN
;
5810 V_UNKNOWN(&v
) = (IUnknown
*)&u
.IDispatch_iface
;
5811 hres
= VariantClear(&v
);
5812 ok(hres
== S_OK
&& u
.ref
== 0 && V_VT(&v
) == VT_EMPTY
,
5813 "clear unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5814 S_OK
, 0, VT_EMPTY
, hres
, u
.ref
, V_VT(&v
));
5816 /* But not when clearing a by-reference*/
5818 V_VT(&v
) = VT_UNKNOWN
|VT_BYREF
;
5819 V_UNKNOWNREF(&v
) = &pu
;
5820 hres
= VariantClear(&v
);
5821 ok(hres
== S_OK
&& u
.ref
== 1 && V_VT(&v
) == VT_EMPTY
,
5822 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5823 S_OK
, 1, VT_EMPTY
, hres
, u
.ref
, V_VT(&v
));
5826 static void test_IUnknownCopy(void)
5829 VARIANTARG vSrc
, vDst
;
5833 init_test_dispatch(1, VT_UI1
, &u
);
5834 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5836 /* AddRef is called on by-value copy */
5838 V_VT(&vSrc
) = VT_UNKNOWN
;
5839 V_UNKNOWN(&vSrc
) = pu
;
5840 hres
= VariantCopy(&vDst
, &vSrc
);
5841 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vDst
) == VT_UNKNOWN
,
5842 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5843 S_OK
, 2, VT_EMPTY
, hres
, u
.ref
, V_VT(&vDst
));
5845 /* AddRef is skipped on copy of by-reference IDispatch */
5848 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5849 V_UNKNOWNREF(&vSrc
) = &pu
;
5850 hres
= VariantCopy(&vDst
, &vSrc
);
5851 ok(hres
== S_OK
&& u
.ref
== 1 && V_VT(&vDst
) == (VT_UNKNOWN
|VT_BYREF
),
5852 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5853 S_OK
, 1, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vDst
));
5855 /* AddRef is called copying by-reference IDispatch with indirection */
5858 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5859 V_UNKNOWNREF(&vSrc
) = &pu
;
5860 hres
= VariantCopyInd(&vDst
, &vSrc
);
5861 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vDst
) == VT_UNKNOWN
,
5862 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5863 S_OK
, 2, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vDst
));
5865 /* Indirection in place also calls AddRef */
5867 V_VT(&vSrc
) = VT_UNKNOWN
|VT_BYREF
;
5868 V_UNKNOWNREF(&vSrc
) = &pu
;
5869 hres
= VariantCopyInd(&vSrc
, &vSrc
);
5870 ok(hres
== S_OK
&& u
.ref
== 2 && V_VT(&vSrc
) == VT_UNKNOWN
,
5871 "copy unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5872 S_OK
, 2, VT_DISPATCH
, hres
, u
.ref
, V_VT(&vSrc
));
5875 static void test_IUnknownChangeTypeEx(void)
5878 VARIANTARG vSrc
, vDst
;
5884 init_test_dispatch(1, VT_UI1
, &u
);
5885 pu
= (IUnknown
*)&u
.IDispatch_iface
;
5887 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
5889 V_VT(&vSrc
) = VT_UNKNOWN
;
5890 V_UNKNOWN(&vSrc
) = pu
;
5892 /* =>IDispatch in place */
5893 hres
= VariantChangeTypeEx(&vSrc
, &vSrc
, lcid
, 0, VT_DISPATCH
);
5894 ok(hres
== S_OK
&& u
.ref
== 1 &&
5895 V_VT(&vSrc
) == VT_DISPATCH
&& V_DISPATCH(&vSrc
) == (IDispatch
*)pu
,
5896 "change unk(src=src): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
5897 S_OK
, 1, VT_DISPATCH
, pu
, hres
, u
.ref
, V_VT(&vSrc
), V_DISPATCH(&vSrc
));
5901 V_VT(&vSrc
) = VT_UNKNOWN
;
5902 V_UNKNOWN(&vSrc
) = pu
;
5904 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
5905 /* Note vSrc is not cleared, as final refcount is 2 */
5906 ok(hres
== S_OK
&& u
.ref
== 2 &&
5907 V_VT(&vDst
) == VT_UNKNOWN
&& V_UNKNOWN(&vDst
) == pu
,
5908 "change unk(src,dst): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
5909 S_OK
, 2, VT_UNKNOWN
, pu
, hres
, u
.ref
, V_VT(&vDst
), V_UNKNOWN(&vDst
));
5911 /* Can't change unknown to anything else */
5912 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
5914 HRESULT hExpected
= DISP_E_BADVARTYPE
;
5916 V_VT(&vSrc
) = VT_UNKNOWN
;
5917 V_UNKNOWN(&vSrc
) = pu
;
5920 if (vt
== VT_UNKNOWN
|| vt
== VT_DISPATCH
|| vt
== VT_EMPTY
|| vt
== VT_NULL
)
5924 if (vt
== VT_I8
|| vt
== VT_UI8
)
5927 hExpected
= DISP_E_TYPEMISMATCH
;
5929 else if (vt
== VT_RECORD
)
5931 hExpected
= DISP_E_TYPEMISMATCH
;
5933 else if (vt
>= VT_I2
&& vt
<= VT_UINT
&& vt
!= (VARTYPE
)15)
5934 hExpected
= DISP_E_TYPEMISMATCH
;
5937 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
5938 ok(hres
== hExpected
,
5939 "change unk(badvar): vt %d expected 0x%08x, got 0x%08x\n",
5940 vt
, hExpected
, hres
);
5945 static void test_IDispatchClear(void)
5952 init_test_dispatch(1, VT_UI1
, &d
);
5953 pd
= &d
.IDispatch_iface
;
5955 /* As per IUnknown */
5957 V_VT(&v
) = VT_DISPATCH
;
5958 V_DISPATCH(&v
) = pd
;
5959 hres
= VariantClear(&v
);
5960 ok(hres
== S_OK
&& d
.ref
== 0 && V_VT(&v
) == VT_EMPTY
,
5961 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5962 S_OK
, 0, VT_EMPTY
, hres
, d
.ref
, V_VT(&v
));
5965 V_VT(&v
) = VT_DISPATCH
|VT_BYREF
;
5966 V_DISPATCHREF(&v
) = &pd
;
5967 hres
= VariantClear(&v
);
5968 ok(hres
== S_OK
&& d
.ref
== 1 && V_VT(&v
) == VT_EMPTY
,
5969 "clear dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5970 S_OK
, 1, VT_EMPTY
, hres
, d
.ref
, V_VT(&v
));
5973 static void test_IDispatchCopy(void)
5976 VARIANTARG vSrc
, vDst
;
5980 init_test_dispatch(1, VT_UI1
, &d
);
5981 pd
= &d
.IDispatch_iface
;
5983 /* As per IUnknown */
5986 V_VT(&vSrc
) = VT_DISPATCH
;
5987 V_DISPATCH(&vSrc
) = pd
;
5988 hres
= VariantCopy(&vDst
, &vSrc
);
5989 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vDst
) == VT_DISPATCH
,
5990 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
5991 S_OK
, 2, VT_EMPTY
, hres
, d
.ref
, V_VT(&vDst
));
5995 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
5996 V_DISPATCHREF(&vSrc
) = &pd
;
5997 hres
= VariantCopy(&vDst
, &vSrc
);
5998 ok(hres
== S_OK
&& d
.ref
== 1 && V_VT(&vDst
) == (VT_DISPATCH
|VT_BYREF
),
5999 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
6000 S_OK
, 1, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vDst
));
6004 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
6005 V_DISPATCHREF(&vSrc
) = &pd
;
6006 hres
= VariantCopyInd(&vDst
, &vSrc
);
6007 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vDst
) == VT_DISPATCH
,
6008 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
6009 S_OK
, 2, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vDst
));
6012 V_VT(&vSrc
) = VT_DISPATCH
|VT_BYREF
;
6013 V_DISPATCHREF(&vSrc
) = &pd
;
6014 hres
= VariantCopyInd(&vSrc
, &vSrc
);
6015 ok(hres
== S_OK
&& d
.ref
== 2 && V_VT(&vSrc
) == VT_DISPATCH
,
6016 "copy dispatch: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
6017 S_OK
, 2, VT_DISPATCH
, hres
, d
.ref
, V_VT(&vSrc
));
6020 static void test_IDispatchChangeTypeEx(void)
6023 VARIANTARG vSrc
, vDst
;
6028 init_test_dispatch(1, VT_UI1
, &d
);
6029 pd
= &d
.IDispatch_iface
;
6031 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6033 V_VT(&vSrc
) = VT_DISPATCH
;
6034 V_DISPATCH(&vSrc
) = pd
;
6036 /* =>IUnknown in place */
6037 hres
= VariantChangeTypeEx(&vSrc
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
6038 ok(hres
== S_OK
&& d
.ref
== 1 &&
6039 V_VT(&vSrc
) == VT_UNKNOWN
&& V_UNKNOWN(&vSrc
) == (IUnknown
*)pd
,
6040 "change disp(src=src): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
6041 S_OK
, 1, VT_UNKNOWN
, pd
, hres
, d
.ref
, V_VT(&vSrc
), V_UNKNOWN(&vSrc
));
6045 V_VT(&vSrc
) = VT_DISPATCH
;
6046 V_DISPATCH(&vSrc
) = pd
;
6048 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_UNKNOWN
);
6049 /* Note vSrc is not cleared, as final refcount is 2 */
6050 ok(hres
== S_OK
&& d
.ref
== 2 &&
6051 V_VT(&vDst
) == VT_UNKNOWN
&& V_UNKNOWN(&vDst
) == (IUnknown
*)pd
,
6052 "change disp(src,dst): expected 0x%08x,%d,%d,%p, got 0x%08x,%d,%d,%p\n",
6053 S_OK
, 2, VT_UNKNOWN
, pd
, hres
, d
.ref
, V_VT(&vDst
), V_UNKNOWN(&vDst
));
6055 /* FIXME: Verify that VARIANT_NOVALUEPROP prevents conversion to integral
6056 * types. this requires that the xxxFromDisp tests work first.
6061 static void test_ErrorChangeTypeEx(void)
6064 VARIANTARG vSrc
, vDst
;
6068 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6070 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
6072 HRESULT hExpected
= DISP_E_BADVARTYPE
;
6074 V_VT(&vSrc
) = VT_ERROR
;
6077 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6083 if (vt
== VT_I8
|| vt
== VT_UI8
)
6086 hExpected
= DISP_E_TYPEMISMATCH
;
6088 else if (vt
== VT_RECORD
)
6090 hExpected
= DISP_E_TYPEMISMATCH
;
6092 else if (vt
<= VT_UINT
&& vt
!= (VARTYPE
)15)
6093 hExpected
= DISP_E_TYPEMISMATCH
;
6096 ok(hres
== hExpected
,
6097 "change err: vt %d expected 0x%08x, got 0x%08x\n", vt
, hExpected
, hres
);
6102 static void test_EmptyChangeTypeEx(void)
6107 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6109 for (vt
= VT_EMPTY
; vt
<= VT_BSTR_BLOB
; vt
++)
6111 HRESULT hExpected
, hres
;
6112 VARIANTARG vSrc
, vDst
;
6114 /* skip for undefined types */
6115 if ((vt
== 15) || (vt
> VT_VERSIONED_STREAM
&& vt
< VT_BSTR_BLOB
))
6125 hExpected
= DISP_E_BADVARTYPE
;
6132 hExpected
= DISP_E_TYPEMISMATCH
;
6154 hExpected
= DISP_E_BADVARTYPE
;
6158 V_VT(&vSrc
) = VT_EMPTY
;
6159 memset(&vDst
, 0, sizeof(vDst
));
6160 V_VT(&vDst
) = VT_NULL
;
6162 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6163 ok(hres
== hExpected
, "change empty: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6164 vt
, hExpected
, hres
, V_VT(&vDst
));
6167 ok(V_VT(&vDst
) == vt
, "change empty: vt %d, got %d\n", vt
, V_VT(&vDst
));
6168 VariantClear(&vDst
);
6174 static void test_NullChangeTypeEx(void)
6179 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6181 for (vt
= VT_EMPTY
; vt
<= VT_BSTR_BLOB
; vt
++)
6183 VARIANTARG vSrc
, vDst
;
6184 HRESULT hExpected
, hres
;
6186 /* skip for undefined types */
6187 if ((vt
== 15) || (vt
> VT_VERSIONED_STREAM
&& vt
< VT_BSTR_BLOB
))
6195 hExpected
= DISP_E_TYPEMISMATCH
;
6197 hExpected
= DISP_E_BADVARTYPE
;
6223 hExpected
= DISP_E_TYPEMISMATCH
;
6226 hExpected
= DISP_E_BADVARTYPE
;
6230 V_VT(&vSrc
) = VT_NULL
;
6231 memset(&vDst
, 0, sizeof(vDst
));
6232 V_VT(&vDst
) = VT_EMPTY
;
6234 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, vt
);
6235 ok(hres
== hExpected
, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6236 vt
, hExpected
, hres
, V_VT(&vDst
));
6238 /* should work only for VT_NULL -> VT_NULL case */
6240 ok(V_VT(&vDst
) == VT_NULL
, "change null: VT_NULL expected 0x%08x, got 0x%08x, vt %d\n",
6241 hExpected
, hres
, V_VT(&vDst
));
6243 ok(V_VT(&vDst
) == VT_EMPTY
, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
6244 vt
, hExpected
, hres
, V_VT(&vDst
));
6250 static void test_UintChangeTypeEx(void)
6253 VARIANTARG vSrc
, vDst
;
6256 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
);
6258 /* Converting a VT_UINT to a VT_INT does not check for overflow */
6259 V_VT(&vDst
) = VT_EMPTY
;
6260 V_VT(&vSrc
) = VT_UINT
;
6262 hres
= VariantChangeTypeEx(&vDst
, &vSrc
, lcid
, 0, VT_I4
);
6263 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == -1,
6264 "change uint: Expected %d,0x%08x,%d got %d,0x%08x,%d\n",
6265 VT_I4
, S_OK
, -1, V_VT(&vDst
), hres
, V_I4(&vDst
));
6268 #define NUM_CUST_ITEMS 16
6270 static void test_ClearCustData(void)
6275 CHECKPTR(ClearCustData
);
6277 ci
.cCustData
= NUM_CUST_ITEMS
;
6278 ci
.prgCustData
= CoTaskMemAlloc( sizeof(CUSTDATAITEM
) * NUM_CUST_ITEMS
);
6279 for (i
= 0; i
< NUM_CUST_ITEMS
; i
++)
6280 VariantInit(&ci
.prgCustData
[i
].varValue
);
6281 pClearCustData(&ci
);
6282 ok(!ci
.cCustData
&& !ci
.prgCustData
, "ClearCustData didn't clear fields!\n");
6285 static void test_NullByRef(void)
6292 V_VT(&v1
) = VT_BYREF
|VT_VARIANT
;
6295 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_I4
);
6296 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6299 V_VT(&v1
) = VT_BYREF
|VT_VARIANT
;
6304 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_VARIANT
);
6305 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6306 ok(V_VT(&v2
) == VT_I4
&& V_I4(&v2
) == 123, "VariantChangeTypeEx shouldn't change pvargDest\n");
6308 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_BYREF
|VT_I4
);
6309 ok(hRes
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx should return DISP_E_TYPEMISMATCH\n");
6311 hRes
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, 0x3847);
6312 ok(hRes
== DISP_E_BADVARTYPE
, "VariantChangeTypeEx should return DISP_E_BADVARTYPE\n");
6315 /* Dst Variant should remain unchanged if VariantChangeType cannot convert */
6316 static void test_ChangeType_keep_dst(void)
6320 static const WCHAR testW
[] = {'t','e','s','t',0};
6323 bstr
= SysAllocString(testW
);
6326 V_VT(&v1
) = VT_BSTR
;
6328 hres
= VariantChangeTypeEx(&v1
, &v1
, 0, 0, VT_INT
);
6329 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6330 ok(V_VT(&v1
) == VT_BSTR
&& V_BSTR(&v1
) == bstr
, "VariantChangeTypeEx changed dst variant\n");
6333 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_INT
);
6334 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6335 ok(V_VT(&v2
) == VT_INT
&& V_INT(&v2
) == 4, "VariantChangeTypeEx changed dst variant\n");
6336 V_VT(&v2
) = 0xff; /* incorrect variant type */
6337 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_INT
);
6338 ok(hres
== DISP_E_TYPEMISMATCH
, "VariantChangeTypeEx returns %08x\n", hres
);
6339 ok(V_VT(&v2
) == 0xff, "VariantChangeTypeEx changed dst variant\n");
6340 hres
= VariantChangeTypeEx(&v2
, &v1
, 0, 0, VT_BSTR
);
6341 ok(hres
== DISP_E_BADVARTYPE
, "VariantChangeTypeEx returns %08x\n", hres
);
6342 ok(V_VT(&v2
) == 0xff, "VariantChangeTypeEx changed dst variant\n");
6343 SysFreeString(bstr
);
6346 /* This tests assumes an empty cache, so it needs to be ran early in the test. */
6347 static void test_bstr_cache(void)
6349 BSTR str
, str2
, strs
[20];
6352 static const WCHAR testW
[] = {'t','e','s','t',0};
6354 if (GetEnvironmentVariableA("OANOCACHE", NULL
, 0)) {
6355 skip("BSTR cache is disabled, some tests will be skipped.\n");
6359 str
= SysAllocString(testW
);
6360 /* This should put the string into cache */
6362 /* The string is in cache, this won't touch it */
6365 ok(SysStringLen(str
) == 4, "unexpected len\n");
6366 ok(!lstrcmpW(str
, testW
), "string changed\n");
6368 str2
= SysAllocString(testW
);
6369 ok(str
== str2
, "str != str2\n");
6370 SysFreeString(str2
);
6372 /* Fill the bucket with cached entries. */
6373 for(i
=0; i
< sizeof(strs
)/sizeof(*strs
); i
++)
6374 strs
[i
] = SysAllocStringLen(NULL
, 24);
6375 for(i
=0; i
< sizeof(strs
)/sizeof(*strs
); i
++)
6376 SysFreeString(strs
[i
]);
6378 /* Following allocation will be made from cache */
6379 str
= SysAllocStringLen(NULL
, 24);
6380 ok(str
== strs
[0], "str != strs[0]\n");
6382 /* Smaller buffers may also use larget cached buffers */
6383 str2
= SysAllocStringLen(NULL
, 16);
6384 ok(str2
== strs
[1], "str2 != strs[1]\n");
6387 SysFreeString(str2
);
6389 SysFreeString(str2
);
6392 static void write_typelib(int res_no
, const char *filename
)
6399 file
= CreateFileA( filename
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0 );
6400 ok( file
!= INVALID_HANDLE_VALUE
, "file creation failed\n" );
6401 if (file
== INVALID_HANDLE_VALUE
) return;
6402 res
= FindResourceA( GetModuleHandleA(NULL
), (LPCSTR
)MAKEINTRESOURCE(res_no
), "TYPELIB" );
6403 ok( res
!= 0, "couldn't find resource\n" );
6404 ptr
= LockResource( LoadResource( GetModuleHandleA(NULL
), res
));
6405 WriteFile( file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
6406 ok( written
== SizeofResource( GetModuleHandleA(NULL
), res
), "couldn't write resource\n" );
6407 CloseHandle( file
);
6410 static const char *create_test_typelib(int res_no
)
6412 static char filename
[MAX_PATH
];
6414 GetTempFileNameA( ".", "tlb", 0, filename
);
6415 write_typelib(res_no
, filename
);
6419 static void test_recinfo(void)
6421 static const WCHAR testW
[] = {'t','e','s','t',0};
6422 static WCHAR teststructW
[] = {'t','e','s','t','_','s','t','r','u','c','t',0};
6423 static WCHAR teststruct2W
[] = {'t','e','s','t','_','s','t','r','u','c','t','2',0};
6424 static WCHAR teststruct3W
[] = {'t','e','s','t','_','s','t','r','u','c','t','3',0};
6425 WCHAR filenameW
[MAX_PATH
], filename2W
[MAX_PATH
];
6426 ITypeInfo
*typeinfo
, *typeinfo2
, *typeinfo3
;
6427 IRecordInfo
*recinfo
, *recinfo2
, *recinfo3
;
6428 struct test_struct teststruct
, testcopy
;
6429 ITypeLib
*typelib
, *typelib2
;
6430 const char *filename
;
6431 DummyDispatch dispatch
;
6439 filename
= create_test_typelib(2);
6440 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filenameW
, MAX_PATH
);
6441 hr
= LoadTypeLibEx(filenameW
, REGKIND_NONE
, &typelib
);
6442 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6444 filename
= create_test_typelib(3);
6445 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filename2W
, MAX_PATH
);
6446 hr
= LoadTypeLibEx(filename2W
, REGKIND_NONE
, &typelib2
);
6447 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6451 hr
= ITypeLib_FindName(typelib
, teststructW
, 0, &typeinfo
, &memid
, &found
);
6452 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6453 ok(typeinfo
!= NULL
, "got %p\n", typeinfo
);
6454 hr
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
6455 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6456 ok(IsEqualGUID(&attr
->guid
, &UUID_test_struct
), "got %s\n", wine_dbgstr_guid(&attr
->guid
));
6457 ok(attr
->typekind
== TKIND_RECORD
, "got %d\n", attr
->typekind
);
6461 hr
= ITypeLib_FindName(typelib
, teststruct2W
, 0, &typeinfo2
, &memid
, &found
);
6462 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6463 ok(typeinfo2
!= NULL
, "got %p\n", typeinfo2
);
6467 hr
= ITypeLib_FindName(typelib2
, teststruct3W
, 0, &typeinfo3
, &memid
, &found
);
6468 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6469 ok(typeinfo3
!= NULL
, "got %p\n", typeinfo3
);
6471 hr
= GetRecordInfoFromTypeInfo(typeinfo
, &recinfo
);
6472 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6474 hr
= GetRecordInfoFromTypeInfo(typeinfo2
, &recinfo2
);
6475 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6477 hr
= GetRecordInfoFromTypeInfo(typeinfo3
, &recinfo3
);
6478 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6480 /* IsMatchingType, these two records only differ in GUIDs */
6481 ret
= IRecordInfo_IsMatchingType(recinfo
, recinfo2
);
6482 ok(!ret
, "got %d\n", ret
);
6484 /* these two have same GUIDs, but different set of fields */
6485 ret
= IRecordInfo_IsMatchingType(recinfo2
, recinfo3
);
6486 ok(ret
, "got %d\n", ret
);
6488 IRecordInfo_Release(recinfo3
);
6489 ITypeInfo_Release(typeinfo3
);
6490 IRecordInfo_Release(recinfo2
);
6491 ITypeInfo_Release(typeinfo2
);
6494 hr
= IRecordInfo_GetSize(recinfo
, &size
);
6495 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6496 ok(size
== sizeof(struct test_struct
), "got size %d\n", size
);
6497 ok(attr
->cbSizeInstance
== sizeof(struct test_struct
), "got instance size %d\n", attr
->cbSizeInstance
);
6498 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
6501 teststruct
.hr
= E_FAIL
;
6503 teststruct
.disp
= (void*)0xdeadbeef;
6504 teststruct
.bstr
= (void*)0xdeadbeef;
6506 hr
= IRecordInfo_RecordInit(recinfo
, &teststruct
);
6507 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6508 ok(teststruct
.hr
== 0, "got 0x%08x\n", teststruct
.hr
);
6509 ok(teststruct
.b
== 0, "got 0x%08x\n", teststruct
.b
);
6510 ok(teststruct
.disp
== NULL
, "got %p\n", teststruct
.disp
);
6511 ok(teststruct
.bstr
== NULL
, "got %p\n", teststruct
.bstr
);
6513 init_test_dispatch(10, VT_UI1
, &dispatch
);
6515 /* RecordCopy(), interface field reference increased */
6516 teststruct
.hr
= S_FALSE
;
6517 teststruct
.b
= VARIANT_TRUE
;
6518 teststruct
.disp
= &dispatch
.IDispatch_iface
;
6519 teststruct
.bstr
= SysAllocString(testW
);
6520 memset(&testcopy
, 0, sizeof(testcopy
));
6521 hr
= IRecordInfo_RecordCopy(recinfo
, &teststruct
, &testcopy
);
6522 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6523 ok(testcopy
.hr
== S_FALSE
, "got 0x%08x\n", testcopy
.hr
);
6524 ok(testcopy
.b
== VARIANT_TRUE
, "got %d\n", testcopy
.b
);
6525 ok(testcopy
.disp
== teststruct
.disp
, "got %p\n", testcopy
.disp
);
6526 ok(dispatch
.ref
== 11, "got %d\n", dispatch
.ref
);
6527 ok(testcopy
.bstr
!= teststruct
.bstr
, "got %p\n", testcopy
.bstr
);
6528 ok(!lstrcmpW(testcopy
.bstr
, teststruct
.bstr
), "got %s, %s\n", wine_dbgstr_w(testcopy
.bstr
), wine_dbgstr_w(teststruct
.bstr
));
6531 hr
= IRecordInfo_RecordClear(recinfo
, &teststruct
);
6532 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6533 ok(teststruct
.bstr
== NULL
, "got %p\n", teststruct
.bstr
);
6534 hr
= IRecordInfo_RecordClear(recinfo
, &testcopy
);
6535 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6536 ok(testcopy
.bstr
== NULL
, "got %p\n", testcopy
.bstr
);
6538 /* now the destination contains the interface pointer */
6539 memset(&testcopy
, 0, sizeof(testcopy
));
6540 testcopy
.disp
= &dispatch
.IDispatch_iface
;
6543 hr
= IRecordInfo_RecordCopy(recinfo
, &teststruct
, &testcopy
);
6544 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6545 ok(dispatch
.ref
== 9, "got %d\n", dispatch
.ref
);
6547 IRecordInfo_Release(recinfo
);
6549 ITypeInfo_Release(typeinfo
);
6550 ITypeLib_Release(typelib
);
6551 DeleteFileW(filenameW
);
6552 DeleteFileW(filename2W
);
6557 hOleaut32
= GetModuleHandleA("oleaut32.dll");
6559 has_i8
= GetProcAddress(hOleaut32
, "VarI8FromI1") != NULL
;
6560 has_locales
= has_i8
&& GetProcAddress(hOleaut32
, "GetVarConversionLocaleSetting") != NULL
;
6562 trace("LCIDs: System=0x%08x, User=0x%08x\n", GetSystemDefaultLCID(),
6563 GetUserDefaultLCID());
6570 test_VarI1FromUI1();
6571 test_VarI1FromUI2();
6572 test_VarI1FromUI4();
6573 test_VarI1FromUI8();
6574 test_VarI1FromBool();
6577 test_VarI1FromDate();
6579 test_VarI1FromDec();
6580 test_VarI1FromStr();
6581 test_VarUI1FromDisp();
6583 test_VarI1ChangeTypeEx();
6585 test_VarUI1FromI1();
6586 test_VarUI1FromI2();
6587 test_VarUI1FromI4();
6588 test_VarUI1FromI8();
6589 test_VarUI1FromUI2();
6590 test_VarUI1FromUI4();
6591 test_VarUI1FromUI8();
6592 test_VarUI1FromBool();
6593 test_VarUI1FromR4();
6594 test_VarUI1FromR8();
6595 test_VarUI1FromDate();
6596 test_VarUI1FromCy();
6597 test_VarUI1FromDec();
6598 test_VarUI1FromStr();
6600 test_VarUI1ChangeTypeEx();
6605 test_VarI2FromUI1();
6606 test_VarI2FromUI2();
6607 test_VarI2FromUI4();
6608 test_VarI2FromUI8();
6609 test_VarI2FromBool();
6612 test_VarI2FromDate();
6614 test_VarI2FromDec();
6615 test_VarI2FromStr();
6617 test_VarI2ChangeTypeEx();
6619 test_VarUI2FromI1();
6620 test_VarUI2FromI2();
6621 test_VarUI2FromI4();
6622 test_VarUI2FromI8();
6623 test_VarUI2FromUI1();
6624 test_VarUI2FromUI4();
6625 test_VarUI2FromUI8();
6626 test_VarUI2FromBool();
6627 test_VarUI2FromR4();
6628 test_VarUI2FromR8();
6629 test_VarUI2FromDate();
6630 test_VarUI2FromCy();
6631 test_VarUI2FromDec();
6632 test_VarUI2FromStr();
6634 test_VarUI2ChangeTypeEx();
6639 test_VarI4FromUI1();
6640 test_VarI4FromUI2();
6641 test_VarI4FromUI4();
6642 test_VarI4FromUI8();
6643 test_VarI4FromBool();
6646 test_VarI4FromDate();
6648 test_VarI4FromDec();
6649 test_VarI4FromStr();
6651 test_VarI4ChangeTypeEx();
6653 test_VarUI4FromI1();
6654 test_VarUI4FromI2();
6655 test_VarUI4FromUI2();
6656 test_VarUI4FromI8();
6657 test_VarUI4FromUI1();
6658 test_VarUI4FromI4();
6659 test_VarUI4FromUI8();
6660 test_VarUI4FromBool();
6661 test_VarUI4FromR4();
6662 test_VarUI4FromR8();
6663 test_VarUI4FromDate();
6664 test_VarUI4FromCy();
6665 test_VarUI4FromDec();
6666 test_VarUI4FromStr();
6668 test_VarUI4ChangeTypeEx();
6671 test_VarI8FromUI1();
6673 test_VarI8FromUI2();
6674 test_VarI8FromUI4();
6677 test_VarI8FromBool();
6678 test_VarI8FromUI8();
6680 test_VarI8FromDec();
6681 test_VarI8FromDate();
6682 test_VarI8FromStr();
6684 test_VarI8ChangeTypeEx();
6686 test_VarUI8FromI1();
6687 test_VarUI8FromUI1();
6688 test_VarUI8FromI2();
6689 test_VarUI8FromUI2();
6690 test_VarUI8FromUI4();
6691 test_VarUI8FromR4();
6692 test_VarUI8FromR8();
6693 test_VarUI8FromBool();
6694 test_VarUI8FromI8();
6695 test_VarUI8FromCy();
6696 test_VarUI8FromDec();
6697 test_VarUI8FromDate();
6698 test_VarUI8FromStr();
6700 test_VarUI8ChangeTypeEx();
6703 test_VarR4FromUI1();
6705 test_VarR4FromUI2();
6707 test_VarR4FromUI4();
6709 test_VarR4FromBool();
6712 test_VarR4FromUI8();
6713 test_VarR4FromDec();
6714 test_VarR4FromDate();
6715 test_VarR4FromStr();
6717 test_VarR4ChangeTypeEx();
6720 test_VarR8FromUI1();
6722 test_VarR8FromUI2();
6724 test_VarR8FromUI4();
6726 test_VarR8FromBool();
6729 test_VarR8FromUI8();
6730 test_VarR8FromDec();
6731 test_VarR8FromDate();
6732 test_VarR8FromStr();
6734 test_VarR8ChangeTypeEx();
6737 test_VarDateFromI1();
6738 test_VarDateFromUI1();
6739 test_VarDateFromI2();
6740 test_VarDateFromUI2();
6741 test_VarDateFromI4();
6742 test_VarDateFromUI4();
6743 test_VarDateFromR4();
6744 test_VarDateFromR8();
6745 test_VarDateFromBool();
6746 test_VarDateFromCy();
6747 test_VarDateFromI8();
6748 test_VarDateFromUI8();
6749 test_VarDateFromDec();
6750 test_VarDateFromStr();
6752 test_VarDateChangeTypeEx();
6755 test_VarCyFromUI1();
6757 test_VarCyFromUI2();
6759 test_VarCyFromUI4();
6762 test_VarCyFromBool();
6764 test_VarCyFromUI8();
6765 test_VarCyFromDec();
6766 test_VarCyFromDate();
6781 test_VarDecFromI1();
6782 test_VarDecFromI2();
6783 test_VarDecFromI4();
6784 test_VarDecFromI8();
6785 test_VarDecFromUI1();
6786 test_VarDecFromUI2();
6787 test_VarDecFromUI4();
6788 test_VarDecFromUI8();
6789 test_VarDecFromR4();
6790 test_VarDecFromR8();
6791 test_VarDecFromDate();
6792 test_VarDecFromStr();
6793 test_VarDecFromCy();
6794 test_VarDecFromDate();
6795 test_VarDecFromBool();
6807 test_VarBoolFromI1();
6808 test_VarBoolFromUI1();
6809 test_VarBoolFromI2();
6810 test_VarBoolFromUI2();
6811 test_VarBoolFromI4();
6812 test_VarBoolFromUI4();
6813 test_VarBoolFromR4();
6814 test_VarBoolFromR8();
6815 test_VarBoolFromCy();
6816 test_VarBoolFromI8();
6817 test_VarBoolFromUI8();
6818 test_VarBoolFromDec();
6819 test_VarBoolFromDate();
6820 test_VarBoolFromStr();
6822 test_VarBoolChangeTypeEx();
6824 test_VarBstrFromR4();
6825 test_VarBstrFromDate();
6826 test_VarBstrFromCy();
6827 test_VarBstrFromDec();
6829 test_SysStringLen();
6830 test_SysStringByteLen();
6831 test_SysAllocString();
6832 test_SysAllocStringLen();
6833 test_SysAllocStringByteLen();
6834 test_SysReAllocString();
6835 test_SysReAllocStringLen();
6839 test_IUnknownClear();
6840 test_IUnknownCopy();
6841 test_IUnknownChangeTypeEx();
6843 test_IDispatchClear();
6844 test_IDispatchCopy();
6845 test_IDispatchChangeTypeEx();
6847 test_ErrorChangeTypeEx();
6848 test_EmptyChangeTypeEx();
6849 test_NullChangeTypeEx();
6850 test_UintChangeTypeEx();
6852 test_ClearCustData();
6855 test_ChangeType_keep_dst();