ReactOS 0.4.16-dev-295-g4aee028
CComVariant.cpp File Reference
#include <apitest.h>
#include <atlbase.h>
#include <versionhelpers.h>
Include dependency graph for CComVariant.cpp:

Go to the source code of this file.

Macros

#define ATLASSERT(x)
 
#define _ATL_NO_VARIANT_THROW
 
#define expect_bool   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_bool_imp
 
#define expect_int   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_int_imp
 
#define expect_uint   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_uint_imp
 
#define expect_double   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_double_imp
 
#define expect_error   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_error_imp
 
#define expect_empty   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_empty_imp
 

Functions

void expect_bool_imp (const CComVariant &ccv, bool value)
 
void expect_int_imp (const CComVariant &ccv, int value, unsigned short type)
 
void expect_uint_imp (const CComVariant &ccv, unsigned int value, unsigned short type)
 
void expect_double_imp (const CComVariant &ccv, double value, unsigned short type)
 
void expect_error_imp (const CComVariant &ccv, SCODE value)
 
void expect_empty_imp (const CComVariant &ccv)
 
static void test_construction ()
 
static void test_copyconstructor ()
 
static void test_assign ()
 
static void test_misc ()
 
 START_TEST (CComVariant)
 

Macro Definition Documentation

◆ _ATL_NO_VARIANT_THROW

#define _ATL_NO_VARIANT_THROW

Definition at line 11 of file CComVariant.cpp.

◆ ATLASSERT

#define ATLASSERT (   x)

Definition at line 10 of file CComVariant.cpp.

◆ expect_bool

#define expect_bool   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_bool_imp

Definition at line 55 of file CComVariant.cpp.

◆ expect_double

#define expect_double   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_double_imp

Definition at line 58 of file CComVariant.cpp.

◆ expect_empty

#define expect_empty   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_empty_imp

Definition at line 60 of file CComVariant.cpp.

◆ expect_error

#define expect_error   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_error_imp

Definition at line 59 of file CComVariant.cpp.

◆ expect_int

#define expect_int   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_int_imp

Definition at line 56 of file CComVariant.cpp.

◆ expect_uint

#define expect_uint   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_uint_imp

Definition at line 57 of file CComVariant.cpp.

Function Documentation

◆ expect_bool_imp()

void expect_bool_imp ( const CComVariant &  ccv,
bool  value 
)

Definition at line 17 of file CComVariant.cpp.

18{
19 winetest_ok(V_VT(&ccv) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&ccv));
20 VARIANT_BOOL expected = (value ? VARIANT_TRUE : VARIANT_FALSE);
21 winetest_ok(V_BOOL(&ccv) == expected, "Expected value to be %u, was: %u\n", expected, V_BOOL(&ccv));
22}
short VARIANT_BOOL
Definition: compat.h:2290
@ VT_BOOL
Definition: compat.h:2306
BOOL expected
Definition: store.c:2063
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_VT(A)
Definition: oleauto.h:211
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
Definition: pdh_main.c:94

◆ expect_double_imp()

void expect_double_imp ( const CComVariant &  ccv,
double  value,
unsigned short  type 
)

Definition at line 36 of file CComVariant.cpp.

37{
38 winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
39 winetest_ok(V_R8(&ccv) == value, "Expected value to be %f, was: %f\n", value, V_R8(&ccv));
40}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define V_R8(A)
Definition: oleauto.h:262

◆ expect_empty_imp()

void expect_empty_imp ( const CComVariant &  ccv)

Definition at line 48 of file CComVariant.cpp.

49{
50 winetest_ok(V_VT(&ccv) == VT_EMPTY, "Expected .vt to be VT_EMPTY, was %u\n", V_VT(&ccv));
52 winetest_ok(V_I8(&ccv) == 0ll, "Expected value to be 0, was: %I64d\n", V_I8(&ccv));
53}
static BOOL IsWindows8OrGreater()
w ll
Definition: byte_order.h:167
@ VT_EMPTY
Definition: compat.h:2295
#define V_I8(A)
Definition: oleauto.h:249

◆ expect_error_imp()

void expect_error_imp ( const CComVariant &  ccv,
SCODE  value 
)

Definition at line 42 of file CComVariant.cpp.

43{
44 winetest_ok(V_VT(&ccv) == VT_ERROR, "Expected .vt to be VT_ERROR, was %u\n", V_VT(&ccv));
45 winetest_ok(V_ERROR(&ccv) == value, "Expected value to be %lx, was: %lx\n", value, V_ERROR(&ccv));
46}
@ VT_ERROR
Definition: compat.h:2305
#define V_ERROR(A)
Definition: oleauto.h:241

◆ expect_int_imp()

void expect_int_imp ( const CComVariant &  ccv,
int  value,
unsigned short  type 
)

Definition at line 24 of file CComVariant.cpp.

25{
26 winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
27 winetest_ok(V_I4(&ccv) == value, "Expected value to be %d, was: %ld\n", value, V_I4(&ccv));
28}
#define V_I4(A)
Definition: oleauto.h:247

◆ expect_uint_imp()

void expect_uint_imp ( const CComVariant &  ccv,
unsigned int  value,
unsigned short  type 
)

Definition at line 30 of file CComVariant.cpp.

31{
32 winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
33 winetest_ok(V_UI4(&ccv) == value, "Expected value to be %u, was: %lu\n", value, V_UI4(&ccv));
34}
#define V_UI4(A)
Definition: oleauto.h:270

◆ START_TEST()

START_TEST ( CComVariant  )

Definition at line 468 of file CComVariant.cpp.

469{
472 test_assign();
473 test_misc();
474}
static void test_construction()
Definition: CComVariant.cpp:63
static void test_copyconstructor()
static void test_assign()
static void test_misc()

◆ test_assign()

static void test_assign ( )
static

Definition at line 271 of file CComVariant.cpp.

272{
273 {
274 CComVariant empty;
275 CComVariant empty2 = empty;
276 expect_empty(empty2);
277 }
278 {
279 CComBSTR bstr(L"TESTW");
280 CComVariant olestr = (LPCOLESTR)bstr;
281 ok(V_VT(&olestr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr));
282 ok(!wcscmp(V_BSTR(&olestr), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr)));
283 CComVariant olestr2 = olestr;
284 ok(V_VT(&olestr2) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr2));
285 ok(!wcscmp(V_BSTR(&olestr2), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr2)));
286 }
287 {
288 CComVariant trueVal = true;
289 ok(V_VT(&trueVal) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal));
290 ok(V_BOOL(&trueVal) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal));
291 CComVariant trueVal2 = trueVal;
292 ok(V_VT(&trueVal2) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal2));
293 ok(V_BOOL(&trueVal2) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal2));
294 }
295 {
296 CComVariant b1 = (BYTE)33;
297 ok(V_VT(&b1) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b1));
298 ok(V_UI1(&b1) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b1));
299 CComVariant b2 = b1;
300 ok(V_VT(&b2) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b2));
301 ok(V_UI1(&b2) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b2));
302 }
303 {
304 CComVariant c1 = (char)33;
305 ok(V_VT(&c1) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c1));
306 ok(V_I1(&c1) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c1));
307 CComVariant c2 = c1;
308 ok(V_VT(&c2) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c2));
309 ok(V_I1(&c2) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c2));
310 }
311 {
312 CComVariant s1 = (short)12345;
313 ok(V_VT(&s1) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s1));
314 ok(V_I2(&s1) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s1));
315 CComVariant s2 = s1;
316 ok(V_VT(&s2) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s2));
317 ok(V_I2(&s2) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s2));
318 }
319 {
320 CComVariant us1 = (unsigned short)12345;
321 ok(V_VT(&us1) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us1));
322 ok(V_UI2(&us1) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us1));
323 CComVariant us2 = us1;
324 ok(V_VT(&us2) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us2));
325 ok(V_UI2(&us2) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us2));
326 }
327 {
328 CComVariant i1 = (int)4;
329 expect_int(i1, 4, VT_I4);
330 CComVariant i2 = i1;
331 expect_int(i2, 4, VT_I4);
332 }
333 {
334 CComVariant ui1 = (unsigned int)4;
335 expect_uint(ui1, 4, VT_UI4);
336 CComVariant ui2 = ui1;
337 expect_uint(ui2, 4, VT_UI4);
338 }
339 {
340 CComVariant l1 = (long)4;
341 expect_uint(l1, 4, VT_I4);
342 CComVariant l2 = l1;
343 expect_uint(l2, 4, VT_I4);
344 }
345 {
346 CComVariant ul1 = (unsigned long)33;
347 expect_uint(ul1, 33, VT_UI4);
348 CComVariant ul2 = ul1;
349 expect_uint(ul2, 33, VT_UI4);
350 }
351 {
352 CComVariant f1 = 3.4f;
353 ok(V_VT(&f1) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f1));
354 ok(V_R4(&f1) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f1));
355 CComVariant f2 = f1;
356 ok(V_VT(&f2) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f2));
357 ok(V_R4(&f2) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f2));
358 }
359 {
360 CComVariant d1 = 3.4;
361 expect_double(d1, 3.4, VT_R8);
362 CComVariant d2 = d1;
363 expect_double(d2, 3.4, VT_R8);
364 }
365 {
366 LONGLONG lv = 12030912309123ll;
367 CComVariant l1 = lv;
368 ok(V_VT(&l1) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l1));
369 ok(V_I8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l1)));
370 CComVariant l2 = l1;
371 ok(V_VT(&l2) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l2));
372 ok(V_I8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l2)));
373 }
374 {
375 ULONGLONG lv = 12030912309123ull;
376 CComVariant l1 = lv;
377 ok(V_VT(&l1) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l1));
378 ok(V_UI8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l1)));
379 CComVariant l2 = l1;
380 ok(V_VT(&l2) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l2));
381 ok(V_UI8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l2)));
382 }
383 {
384 CY cy;
385 cy.int64 = 12030912309123ll;
386 CComVariant c1 = cy;
387 ok(V_VT(&c1) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&c1));
388 ok(V_CY(&c1).int64 == cy.int64, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(cy.int64), wine_dbgstr_longlong(V_CY(&c1).int64));
389 CComVariant c2 = c1;
390 ok(V_VT(&c2) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&c2));
391 ok(V_CY(&c2).int64 == cy.int64, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(cy.int64), wine_dbgstr_longlong(V_CY(&c2).int64));
392 }
393 // IDispatch
394 // IUnknown
395}
#define expect_int
Definition: CComVariant.cpp:56
#define expect_uint
Definition: CComVariant.cpp:57
#define expect_empty
Definition: CComVariant.cpp:60
#define expect_double
Definition: CComVariant.cpp:58
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR empty[]
Definition: main.c:47
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
@ VT_UI8
Definition: compat.h:2315
@ VT_BSTR
Definition: compat.h:2303
@ VT_R4
Definition: compat.h:2299
@ VT_UI2
Definition: compat.h:2312
@ VT_R8
Definition: compat.h:2300
@ VT_CY
Definition: compat.h:2301
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
@ VT_UI1
Definition: compat.h:2311
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned char
Definition: typeof.h:29
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
long long int64
Definition: platform.h:13
#define wine_dbgstr_w
Definition: kernel32.h:34
struct S1 s1
struct S2 s2
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
#define L(x)
Definition: ntvdm.h:50
#define V_UI1(A)
Definition: oleauto.h:266
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_R4(A)
Definition: oleauto.h:260
#define V_CY(A)
Definition: oleauto.h:229
#define V_UI8(A)
Definition: oleauto.h:272
#define V_I2(A)
Definition: oleauto.h:245
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define long
Definition: qsort.c:33
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67
Definition: compat.h:2255
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_construction()

static void test_construction ( )
static

Definition at line 63 of file CComVariant.cpp.

64{
65 {
66 CComVariant empty;
68 }
69 {
70 CComBSTR bstr(L"TESTW");
71 CComVariant olestr((LPCOLESTR)bstr), comstr(bstr);
72 ok(V_VT(&olestr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr));
73 ok(!wcscmp(V_BSTR(&olestr), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr)));
74 ok(V_VT(&comstr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&comstr));
75 ok(!wcscmp(V_BSTR(&comstr), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&comstr)));
76 }
77 {
78 CComVariant cstr((LPCSTR)"TESTA");
79 ok(V_VT(&cstr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&cstr));
80 ok(!wcscmp(V_BSTR(&cstr), L"TESTA"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&cstr)));
81 }
82 {
83 CComVariant trueVal(true), falseVal(false);
84 ok(V_VT(&trueVal) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal));
85 ok(V_BOOL(&trueVal) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal));
86 ok(V_VT(&falseVal) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&falseVal));
87 ok(V_BOOL(&falseVal) == VARIANT_FALSE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&falseVal));
88 }
89 {
90 CComVariant b1((BYTE)33);
91 ok(V_VT(&b1) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b1));
92 ok(V_UI1(&b1) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b1));
93 }
94 {
95 CComVariant c1((char)33);
96 ok(V_VT(&c1) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c1));
97 ok(V_I1(&c1) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c1));
98 }
99 {
100 CComVariant s1((short)12345);
101 ok(V_VT(&s1) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s1));
102 ok(V_I2(&s1) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s1));
103 }
104 {
105 CComVariant us1((unsigned short)12345);
106 ok(V_VT(&us1) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us1));
107 ok(V_UI2(&us1) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us1));
108 }
109 {
110 CComVariant i1((int)4, VT_I4), i2((int)3, VT_INT), i3((int)2, VT_I2), i4((int)1);
111 expect_int(i1, 4, VT_I4);
112 expect_int(i2, 3, VT_INT);
114 expect_int(i4, 1, VT_I4);
115 }
116 {
117 CComVariant ui1((unsigned int)4, VT_UI4), ui2((unsigned int)3, VT_UINT), ui3((unsigned int)2, VT_UI2), ui4((unsigned int)1);
118 expect_uint(ui1, 4, VT_UI4);
119 expect_uint(ui2, 3, VT_UINT);
121 expect_uint(ui4, 1, VT_UI4);
122 }
123 {
124 CComVariant l1((long)4, VT_I4), l2((long)3, VT_INT), l3((long)2, VT_ERROR), l4((long)1);
125 expect_int(l1, 4, VT_I4);
127 expect_error(l3, 2);
128 expect_int(l4, 1, VT_I4);
129 }
130 {
131 CComVariant ul1((unsigned long)33);
132 expect_uint(ul1, 33, VT_UI4);
133 }
134 {
135 CComVariant f1(3.4f);
136 ok(V_VT(&f1) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f1));
137 ok(V_R4(&f1) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f1));
138 }
139 {
140 CComVariant d1(3.4, VT_R8), d2(3.4, VT_DATE), d3(8.8, VT_I1), d4(1.9);
141 expect_double(d1, 3.4, VT_R8);
142 expect_double(d2, 3.4, VT_DATE);
144 expect_double(d4, 1.9, VT_R8);
145 }
146 {
147 LONGLONG lv = 12030912309123ll;
148 CComVariant l1(lv);
149 ok(V_VT(&l1) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l1));
150 ok(V_I8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l1)));
151 }
152 {
153 ULONGLONG lv = 12030912309123ull;
154 CComVariant l1(lv);
155 ok(V_VT(&l1) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l1));
156 ok(V_UI8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l1)));
157 }
158 {
159 CY cy;
160 cy.int64 = 12030912309123ll;
161 CComVariant c1(cy);
162 ok(V_VT(&c1) == VT_CY, "Expected .vt to be VT_CY, was %u\n", V_VT(&c1));
163 ok(V_CY(&c1).int64 == cy.int64, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(cy.int64), wine_dbgstr_longlong(V_CY(&c1).int64));
164 }
165 // IDispatch
166 // IUnknown
167}
#define expect_error
Definition: CComVariant.cpp:59
#define E_INVALIDARG
Definition: ddrawi.h:101
@ VT_INT
Definition: compat.h:2316
@ VT_DATE
Definition: compat.h:2302
@ VT_UINT
Definition: compat.h:2317
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by START_TEST().

◆ test_copyconstructor()

static void test_copyconstructor ( )
static

Definition at line 170 of file CComVariant.cpp.

171{
172 {
173 CComVariant empty;
174 CComVariant empty2(empty);
175 expect_empty(empty2);
176 }
177 {
178 CComBSTR bstr(L"TESTW");
179 CComVariant olestr((LPCOLESTR)bstr);
180 CComVariant olestr2(olestr);
181 ok(V_VT(&olestr2) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr2));
182 ok(!wcscmp(V_BSTR(&olestr2), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr2)));
183 }
184 {
185 CComVariant trueVal(true);
186 CComVariant trueVal2(trueVal);
187 ok(V_VT(&trueVal2) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal2));
188 ok(V_BOOL(&trueVal2) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal2));
189 }
190 {
191 CComVariant b1((BYTE)33);
192 CComVariant b2(b1);
193 ok(V_VT(&b2) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b2));
194 ok(V_UI1(&b2) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b2));
195 }
196 {
197 CComVariant c1((char)33);
198 CComVariant c2(c1);
199 ok(V_VT(&c2) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c2));
200 ok(V_I1(&c2) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c2));
201 }
202 {
203 CComVariant s1((short)12345);
204 CComVariant s2(s1);
205 ok(V_VT(&s2) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s2));
206 ok(V_I2(&s2) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s2));
207 }
208 {
209 CComVariant us1((unsigned short)12345);
210 CComVariant us2(us1);
211 ok(V_VT(&us2) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us2));
212 ok(V_UI2(&us2) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us2));
213 }
214 {
215 CComVariant i1((int)4, VT_I4);
216 CComVariant i2(i1);
217 expect_int(i2, 4, VT_I4);
218 }
219 {
220 CComVariant ui1((unsigned int)4, VT_UI4);
221 CComVariant ui2(ui1);
222 expect_uint(ui2, 4, VT_UI4);
223 }
224 {
225 CComVariant l1((long)4, VT_I4);
226 CComVariant l2(l1);
227 expect_uint(l2, 4, VT_I4);
228 }
229 {
230 CComVariant ul1((unsigned long)33);
231 CComVariant ul2(ul1);
232 expect_uint(ul2, 33, VT_UI4);
233 }
234 {
235 CComVariant f1(3.4f);
236 CComVariant f2(f1);
237 ok(V_VT(&f2) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f2));
238 ok(V_R4(&f2) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f2));
239 }
240 {
241 CComVariant d1(3.4, VT_R8);
242 CComVariant d2(d1);
243 expect_double(d2, 3.4, VT_R8);
244 }
245 {
246 LONGLONG lv = 12030912309123ll;
247 CComVariant l1(lv);
248 CComVariant l2(l1);
249 ok(V_VT(&l2) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l2));
250 ok(V_I8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l2)));
251 }
252 {
253 ULONGLONG lv = 12030912309123ull;
254 CComVariant l1(lv);
255 CComVariant l2(l1);
256 ok(V_VT(&l2) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l2));
257 ok(V_UI8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l2)));
258 }
259 {
260 CY cy;
261 cy.int64 = 12030912309123ll;
262 CComVariant c1(cy);
263 CComVariant c2(c1);
264 ok(V_VT(&c2) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&c2));
265 ok(V_CY(&c2).int64 == cy.int64, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(cy.int64), wine_dbgstr_longlong(V_CY(&c2).int64));
266 }
267 // IDispatch
268 // IUnknown
269}

Referenced by START_TEST().

◆ test_misc()

static void test_misc ( )
static

Definition at line 397 of file CComVariant.cpp.

398{
399 HRESULT hr;
400 {
401 CComVariant empty;
402 hr = empty.Clear();
403 ok(SUCCEEDED(hr), "Expected .Clear() to succeed, but it failed: 0x%lx\n", hr);
405 }
406
407 {
408 CComBSTR bstr(L"TESTW");
409 CComVariant olestr((LPCOLESTR)bstr), empty;
410
411 hr = empty.Copy(&olestr); // VARIANT*
412 ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
413 ok(V_VT(&empty) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&empty));
414 ok(!wcscmp(V_BSTR(&empty), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&empty)));
415
416 /* Clear does not null out the rest, it just sets .vt! */
417 hr = olestr.Clear();
418 ok(SUCCEEDED(hr), "Expected .Clear() to succeed, but it failed: 0x%lx\n", hr);
419 ok(V_VT(&olestr) == VT_EMPTY, "Expected .vt to be VT_EMPTY, was %u\n", V_VT(&olestr));
420 }
421
422 {
423 CComVariant d1(3.4, VT_R8), empty;
424 hr = empty.Copy(&d1);
425 ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
427 }
428
429 {
430 LONGLONG lv = 12030912309123ll;
431 CComVariant l1(lv);
432 CComVariant empty;
433 hr = empty.Copy(&l1);
434 ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
435 ok(V_VT(&empty) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&empty));
436 ok(V_I8(&empty) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&empty)));
437 }
438
439 {
440 CY cy;
441 cy.int64 = 12030912309123ll;
442 CComVariant c1(cy);
443 CComVariant empty;
444 hr = empty.Copy(&c1);
445 ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
446 ok(V_VT(&empty) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&empty));
447 ok(V_CY(&empty).int64 == cy.int64, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(cy.int64), wine_dbgstr_longlong(V_CY(&empty).int64));
448 }
449 {
450 CComVariant var = (int)333;
451 CComVariant var2;
452 // var2 = var changed to bstr
453 HRESULT hr = var2.ChangeType(VT_BSTR, &var);
454 ok(SUCCEEDED(hr), "Expected .ChangeType() to succeed, but it failed: 0x%lx\n", hr);
455 expect_int(var, 333, VT_I4);
456 ok(V_VT(&var2) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&var2));
457 ok(!wcscmp(V_BSTR(&var2), L"333"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&var2)));
458
459 // change in place
460 hr = var.ChangeType(VT_BSTR);
461 ok(SUCCEEDED(hr), "Expected .ChangeType() to succeed, but it failed: 0x%lx\n", hr);
462 ok(V_VT(&var) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&var));
463 ok(!wcscmp(V_BSTR(&var), L"333"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&var)));
464 }
465}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const char * var
Definition: shader.c:5666
HRESULT hr
Definition: shlfolder.c:183

Referenced by main_test(), and START_TEST().