ReactOS  0.4.14-dev-866-g5b3e84f
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 10 of file CComVariant.cpp.

◆ ATLASSERT

#define ATLASSERT (   x)

Definition at line 9 of file CComVariant.cpp.

◆ expect_bool

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

Definition at line 54 of file CComVariant.cpp.

◆ expect_double

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

Definition at line 57 of file CComVariant.cpp.

◆ expect_empty

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

Definition at line 59 of file CComVariant.cpp.

◆ expect_error

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

Definition at line 58 of file CComVariant.cpp.

◆ expect_int

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

Definition at line 55 of file CComVariant.cpp.

◆ expect_uint

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

Definition at line 56 of file CComVariant.cpp.

Function Documentation

◆ expect_bool_imp()

void expect_bool_imp ( const CComVariant &  ccv,
bool  value 
)

Definition at line 16 of file CComVariant.cpp.

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

◆ expect_double_imp()

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

Definition at line 35 of file CComVariant.cpp.

36 {
37  winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
38  winetest_ok(V_R8(&ccv) == value, "Expected value to be %f, was: %f\n", value, V_R8(&ccv));
39 }
#define V_R8(A)
Definition: oleauto.h:262
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define V_VT(A)
Definition: oleauto.h:211

◆ expect_empty_imp()

void expect_empty_imp ( const CComVariant &  ccv)

Definition at line 47 of file CComVariant.cpp.

48 {
49  winetest_ok(V_VT(&ccv) == VT_EMPTY, "Expected .vt to be VT_EMPTY, was %u\n", V_VT(&ccv));
50  if (IsWindows8OrGreater())
51  winetest_ok(V_I8(&ccv) == 0ll, "Expected value to be 0, was: %I64d\n", V_I8(&ccv));
52 }
#define V_I8(A)
Definition: oleauto.h:249
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
VERSIONHELPERAPI IsWindows8OrGreater()
#define V_VT(A)
Definition: oleauto.h:211
w ll
Definition: byte_order.h:166

◆ expect_error_imp()

void expect_error_imp ( const CComVariant &  ccv,
SCODE  value 
)

Definition at line 41 of file CComVariant.cpp.

42 {
43  winetest_ok(V_VT(&ccv) == VT_ERROR, "Expected .vt to be VT_ERROR, was %u\n", V_VT(&ccv));
44  winetest_ok(V_ERROR(&ccv) == value, "Expected value to be %lx, was: %lx\n", value, V_ERROR(&ccv));
45 }
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define V_VT(A)
Definition: oleauto.h:211
#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 23 of file CComVariant.cpp.

24 {
25  winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
26  winetest_ok(V_I4(&ccv) == value, "Expected value to be %d, was: %ld\n", value, V_I4(&ccv));
27 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define V_I4(A)
Definition: oleauto.h:247
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define V_VT(A)
Definition: oleauto.h:211

◆ expect_uint_imp()

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

Definition at line 29 of file CComVariant.cpp.

30 {
31  winetest_ok(V_VT(&ccv) == type, "Expected .vt to be %u, was %u\n", type, V_VT(&ccv));
32  winetest_ok(V_UI4(&ccv) == value, "Expected value to be %u, was: %lu\n", value, V_UI4(&ccv));
33 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define V_UI4(A)
Definition: oleauto.h:270
#define V_VT(A)
Definition: oleauto.h:211

◆ START_TEST()

START_TEST ( CComVariant  )

Definition at line 467 of file CComVariant.cpp.

468 {
471  test_assign();
472  test_misc();
473 }
static void test_construction()
Definition: CComVariant.cpp:62
static void test_copyconstructor()
static void test_assign()
static void test_misc()

◆ test_assign()

static void test_assign ( )
static

Definition at line 270 of file CComVariant.cpp.

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

Referenced by START_TEST().

◆ test_construction()

static void test_construction ( )
static

Definition at line 62 of file CComVariant.cpp.

63 {
64  {
65  CComVariant empty;
67  }
68  {
69  CComBSTR bstr(L"TESTW");
70  CComVariant olestr((LPCOLESTR)bstr), comstr(bstr);
71  ok(V_VT(&olestr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr));
72  ok(!wcscmp(V_BSTR(&olestr), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr)));
73  ok(V_VT(&comstr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&comstr));
74  ok(!wcscmp(V_BSTR(&comstr), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&comstr)));
75  }
76  {
77  CComVariant cstr((LPCSTR)"TESTA");
78  ok(V_VT(&cstr) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&cstr));
79  ok(!wcscmp(V_BSTR(&cstr), L"TESTA"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&cstr)));
80  }
81  {
82  CComVariant trueVal(true), falseVal(false);
83  ok(V_VT(&trueVal) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal));
84  ok(V_BOOL(&trueVal) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal));
85  ok(V_VT(&falseVal) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&falseVal));
86  ok(V_BOOL(&falseVal) == VARIANT_FALSE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&falseVal));
87  }
88  {
89  CComVariant b1((BYTE)33);
90  ok(V_VT(&b1) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b1));
91  ok(V_UI1(&b1) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b1));
92  }
93  {
94  CComVariant c1((char)33);
95  ok(V_VT(&c1) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c1));
96  ok(V_I1(&c1) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c1));
97  }
98  {
99  CComVariant s1((short)12345);
100  ok(V_VT(&s1) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s1));
101  ok(V_I2(&s1) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s1));
102  }
103  {
104  CComVariant us1((unsigned short)12345);
105  ok(V_VT(&us1) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us1));
106  ok(V_UI2(&us1) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us1));
107  }
108  {
109  CComVariant i1((int)4, VT_I4), i2((int)3, VT_INT), i3((int)2, VT_I2), i4((int)1);
110  expect_int(i1, 4, VT_I4);
111  expect_int(i2, 3, VT_INT);
113  expect_int(i4, 1, VT_I4);
114  }
115  {
116  CComVariant ui1((unsigned int)4, VT_UI4), ui2((unsigned int)3, VT_UINT), ui3((unsigned int)2, VT_UI2), ui4((unsigned int)1);
117  expect_uint(ui1, 4, VT_UI4);
118  expect_uint(ui2, 3, VT_UINT);
120  expect_uint(ui4, 1, VT_UI4);
121  }
122  {
123  CComVariant l1((long)4, VT_I4), l2((long)3, VT_INT), l3((long)2, VT_ERROR), l4((long)1);
124  expect_int(l1, 4, VT_I4);
126  expect_error(l3, 2);
127  expect_int(l4, 1, VT_I4);
128  }
129  {
130  CComVariant ul1((unsigned long)33);
131  expect_uint(ul1, 33, VT_UI4);
132  }
133  {
134  CComVariant f1(3.4f);
135  ok(V_VT(&f1) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f1));
136  ok(V_R4(&f1) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f1));
137  }
138  {
139  CComVariant d1(3.4, VT_R8), d2(3.4, VT_DATE), d3(8.8, VT_I1), d4(1.9);
140  expect_double(d1, 3.4, VT_R8);
141  expect_double(d2, 3.4, VT_DATE);
143  expect_double(d4, 1.9, VT_R8);
144  }
145  {
146  LONGLONG lv = 12030912309123ll;
147  CComVariant l1(lv);
148  ok(V_VT(&l1) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l1));
149  ok(V_I8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l1)));
150  }
151  {
152  ULONGLONG lv = 12030912309123ull;
153  CComVariant l1(lv);
154  ok(V_VT(&l1) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l1));
155  ok(V_UI8(&l1) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l1)));
156  }
157  {
158  CY cy;
159  cy.int64 = 12030912309123ll;
160  CComVariant c1(cy);
161  ok(V_VT(&c1) == VT_CY, "Expected .vt to be VT_CY, was %u\n", V_VT(&c1));
162  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));
163  }
164  // IDispatch
165  // IUnknown
166 }
Definition: compat.h:1947
Definition: compat.h:1963
Definition: compat.h:1959
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define V_I2(A)
Definition: oleauto.h:245
#define expect_error
Definition: CComVariant.cpp:58
long long int64
Definition: platform.h:13
#define V_UI8(A)
Definition: oleauto.h:272
Definition: compat.h:1904
#define V_CY(A)
Definition: oleauto.h:229
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
#define E_INVALIDARG
Definition: ddrawi.h:101
#define expect_int
Definition: CComVariant.cpp:55
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
const char * LPCSTR
Definition: xmlstorage.h:183
#define V_I8(A)
Definition: oleauto.h:249
int64_t LONGLONG
Definition: typedefs.h:66
GLfloat f
Definition: glext.h:7540
#define V_R4(A)
Definition: oleauto.h:260
#define expect_double
Definition: CComVariant.cpp:57
struct S1 s1
uint64_t ULONGLONG
Definition: typedefs.h:65
#define V_UI1(A)
Definition: oleauto.h:266
#define V_BOOL(A)
Definition: oleauto.h:224
Definition: compat.h:1948
static const WCHAR L[]
Definition: oid.c:1250
#define V_VT(A)
Definition: oleauto.h:211
unsigned char BYTE
Definition: mem.h:68
Definition: compat.h:1950
#define V_BSTR(A)
Definition: oleauto.h:226
#define expect_empty
Definition: CComVariant.cpp:59
#define f1(x, y, z)
Definition: sha1.c:30
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ok(value,...)
Definition: atltest.h:57
w ll
Definition: byte_order.h:166
BOOL empty
Definition: button.c:170
#define expect_uint
Definition: CComVariant.cpp:56
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
Definition: compat.h:1949
Definition: compat.h:1946

Referenced by START_TEST().

◆ test_copyconstructor()

static void test_copyconstructor ( )
static

Definition at line 169 of file CComVariant.cpp.

170 {
171  {
172  CComVariant empty;
173  CComVariant empty2(empty);
174  expect_empty(empty2);
175  }
176  {
177  CComBSTR bstr(L"TESTW");
178  CComVariant olestr((LPCOLESTR)bstr);
179  CComVariant olestr2(olestr);
180  ok(V_VT(&olestr2) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&olestr2));
181  ok(!wcscmp(V_BSTR(&olestr2), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&olestr2)));
182  }
183  {
184  CComVariant trueVal(true);
185  CComVariant trueVal2(trueVal);
186  ok(V_VT(&trueVal2) == VT_BOOL, "Expected .vt to be BOOL, was %u\n", V_VT(&trueVal2));
187  ok(V_BOOL(&trueVal2) == VARIANT_TRUE, "Expected value to be VARIANT_TRUE, was: %u\n", V_BOOL(&trueVal2));
188  }
189  {
190  CComVariant b1((BYTE)33);
191  CComVariant b2(b1);
192  ok(V_VT(&b2) == VT_UI1, "Expected .vt to be VT_UI1, was %u\n", V_VT(&b2));
193  ok(V_UI1(&b2) == (BYTE)33, "Expected value to be 33, was: %u\n", V_UI1(&b2));
194  }
195  {
196  CComVariant c1((char)33);
197  CComVariant c2(c1);
198  ok(V_VT(&c2) == VT_I1, "Expected .vt to be VT_I1, was %u\n", V_VT(&c2));
199  ok(V_I1(&c2) == (char)33, "Expected value to be 33, was: %d\n", V_I1(&c2));
200  }
201  {
202  CComVariant s1((short)12345);
203  CComVariant s2(s1);
204  ok(V_VT(&s2) == VT_I2, "Expected .vt to be VT_I2, was %u\n", V_VT(&s2));
205  ok(V_I2(&s2) == (short)12345, "Expected value to be 12345, was: %d\n", V_I1(&s2));
206  }
207  {
208  CComVariant us1((unsigned short)12345);
209  CComVariant us2(us1);
210  ok(V_VT(&us2) == VT_UI2, "Expected .vt to be VT_UI2, was %u\n", V_VT(&us2));
211  ok(V_UI2(&us2) == (unsigned short)12345, "Expected value to be 12345, was: %u\n", V_UI2(&us2));
212  }
213  {
214  CComVariant i1((int)4, VT_I4);
215  CComVariant i2(i1);
216  expect_int(i2, 4, VT_I4);
217  }
218  {
219  CComVariant ui1((unsigned int)4, VT_UI4);
220  CComVariant ui2(ui1);
221  expect_uint(ui2, 4, VT_UI4);
222  }
223  {
224  CComVariant l1((long)4, VT_I4);
225  CComVariant l2(l1);
226  expect_uint(l2, 4, VT_I4);
227  }
228  {
229  CComVariant ul1((unsigned long)33);
230  CComVariant ul2(ul1);
231  expect_uint(ul2, 33, VT_UI4);
232  }
233  {
234  CComVariant f1(3.4f);
235  CComVariant f2(f1);
236  ok(V_VT(&f2) == VT_R4, "Expected .vt to be VT_R4, was %u\n", V_VT(&f2));
237  ok(V_R4(&f2) == 3.4f, "Expected value to be 3.4f, was: %f\n", V_R4(&f2));
238  }
239  {
240  CComVariant d1(3.4, VT_R8);
241  CComVariant d2(d1);
242  expect_double(d2, 3.4, VT_R8);
243  }
244  {
245  LONGLONG lv = 12030912309123ll;
246  CComVariant l1(lv);
247  CComVariant l2(l1);
248  ok(V_VT(&l2) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&l2));
249  ok(V_I8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&l2)));
250  }
251  {
252  ULONGLONG lv = 12030912309123ull;
253  CComVariant l1(lv);
254  CComVariant l2(l1);
255  ok(V_VT(&l2) == VT_UI8, "Expected .vt to be VT_UI8, was %u\n", V_VT(&l2));
256  ok(V_UI8(&l2) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_UI8(&l2)));
257  }
258  {
259  CY cy;
260  cy.int64 = 12030912309123ll;
261  CComVariant c1(cy);
262  CComVariant c2(c1);
263  ok(V_VT(&c2) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&c2));
264  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));
265  }
266  // IDispatch
267  // IUnknown
268 }
struct S2 s2
Definition: compat.h:1947
Definition: compat.h:1963
Definition: compat.h:1959
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define V_I2(A)
Definition: oleauto.h:245
long long int64
Definition: platform.h:13
#define V_UI8(A)
Definition: oleauto.h:272
Definition: compat.h:1904
#define V_CY(A)
Definition: oleauto.h:229
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
#define expect_int
Definition: CComVariant.cpp:55
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define V_I8(A)
Definition: oleauto.h:249
int64_t LONGLONG
Definition: typedefs.h:66
GLfloat f
Definition: glext.h:7540
#define V_R4(A)
Definition: oleauto.h:260
#define expect_double
Definition: CComVariant.cpp:57
struct S1 s1
uint64_t ULONGLONG
Definition: typedefs.h:65
#define V_UI1(A)
Definition: oleauto.h:266
#define V_BOOL(A)
Definition: oleauto.h:224
Definition: compat.h:1948
static const WCHAR L[]
Definition: oid.c:1250
#define V_VT(A)
Definition: oleauto.h:211
unsigned char BYTE
Definition: mem.h:68
Definition: compat.h:1950
#define V_BSTR(A)
Definition: oleauto.h:226
#define expect_empty
Definition: CComVariant.cpp:59
#define f1(x, y, z)
Definition: sha1.c:30
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ok(value,...)
Definition: atltest.h:57
w ll
Definition: byte_order.h:166
BOOL empty
Definition: button.c:170
#define expect_uint
Definition: CComVariant.cpp:56
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
int f2(S1 &, S2 &)
Definition: compat.h:1949
Definition: compat.h:1946

Referenced by START_TEST().

◆ test_misc()

static void test_misc ( )
static

Definition at line 396 of file CComVariant.cpp.

397 {
398  HRESULT hr;
399  {
400  CComVariant empty;
401  hr = empty.Clear();
402  ok(SUCCEEDED(hr), "Expected .Clear() to succeed, but it failed: 0x%lx\n", hr);
404  }
405 
406  {
407  CComBSTR bstr(L"TESTW");
408  CComVariant olestr((LPCOLESTR)bstr), empty;
409 
410  hr = empty.Copy(&olestr); // VARIANT*
411  ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
412  ok(V_VT(&empty) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&empty));
413  ok(!wcscmp(V_BSTR(&empty), L"TESTW"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&empty)));
414 
415  /* Clear does not null out the rest, it just sets .vt! */
416  hr = olestr.Clear();
417  ok(SUCCEEDED(hr), "Expected .Clear() to succeed, but it failed: 0x%lx\n", hr);
418  ok(V_VT(&olestr) == VT_EMPTY, "Expected .vt to be VT_EMPTY, was %u\n", V_VT(&olestr));
419  }
420 
421  {
422  CComVariant d1(3.4, VT_R8), empty;
423  hr = empty.Copy(&d1);
424  ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
425  expect_double(empty, 3.4, VT_R8);
426  }
427 
428  {
429  LONGLONG lv = 12030912309123ll;
430  CComVariant l1(lv);
431  CComVariant empty;
432  hr = empty.Copy(&l1);
433  ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
434  ok(V_VT(&empty) == VT_I8, "Expected .vt to be VT_I8, was %u\n", V_VT(&empty));
435  ok(V_I8(&empty) == lv, "Expected value to be %s, was: %s\n", wine_dbgstr_longlong(lv), wine_dbgstr_longlong(V_I8(&empty)));
436  }
437 
438  {
439  CY cy;
440  cy.int64 = 12030912309123ll;
441  CComVariant c1(cy);
442  CComVariant empty;
443  hr = empty.Copy(&c1);
444  ok(SUCCEEDED(hr), "Expected .Copy() to succeed, but it failed: 0x%lx\n", hr);
445  ok(V_VT(&empty) == VT_CY, "Expected .vt to be VT_I8, was %u\n", V_VT(&empty));
446  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));
447  }
448  {
449  CComVariant var = (int)333;
450  CComVariant var2;
451  // var2 = var changed to bstr
452  HRESULT hr = var2.ChangeType(VT_BSTR, &var);
453  ok(SUCCEEDED(hr), "Expected .ChangeType() to succeed, but it failed: 0x%lx\n", hr);
454  expect_int(var, 333, VT_I4);
455  ok(V_VT(&var2) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&var2));
456  ok(!wcscmp(V_BSTR(&var2), L"333"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&var2)));
457 
458  // change in place
459  hr = var.ChangeType(VT_BSTR);
460  ok(SUCCEEDED(hr), "Expected .ChangeType() to succeed, but it failed: 0x%lx\n", hr);
461  ok(V_VT(&var) == VT_BSTR, "Expected .vt to be VT_LPWSTR, was %u\n", V_VT(&var));
462  ok(!wcscmp(V_BSTR(&var), L"333"), "Expected value to be L\"TESTW\", was: %s\n", wine_dbgstr_w(V_BSTR(&var)));
463  }
464 }
Definition: compat.h:1947
Definition: compat.h:1963
HRESULT hr
Definition: shlfolder.c:183
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
long long int64
Definition: platform.h:13
Definition: compat.h:1904
#define V_CY(A)
Definition: oleauto.h:229
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
#define expect_int
Definition: CComVariant.cpp:55
#define V_I8(A)
Definition: oleauto.h:249
int64_t LONGLONG
Definition: typedefs.h:66
LONG HRESULT
Definition: typedefs.h:77
#define expect_double
Definition: CComVariant.cpp:57
static const WCHAR L[]
Definition: oid.c:1250
#define V_VT(A)
Definition: oleauto.h:211
Definition: compat.h:1950
#define V_BSTR(A)
Definition: oleauto.h:226
#define expect_empty
Definition: CComVariant.cpp:59
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ok(value,...)
Definition: atltest.h:57
w ll
Definition: byte_order.h:166
BOOL empty
Definition: button.c:170
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
Definition: compat.h:1949
#define SUCCEEDED(hr)
Definition: intsafe.h:57
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by START_TEST().