ReactOS 0.4.16-dev-734-g364d6e0
propsys.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "initguid.h"
#include "objbase.h"
#include "propsys.h"
#include "propvarutil.h"
#include "strsafe.h"
#include "wine/test.h"
Include dependency graph for propsys.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define GUID_MEMBERS(g)   {(g).Data1, (g).Data2, (g).Data3, {(g).Data4[0], (g).Data4[1], (g).Data4[2], (g).Data4[3], (g).Data4[4], (g).Data4[5], (g).Data4[6], (g).Data4[7]}}
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown *)obj, ref, __LINE__)
 
#define check_PropVariantToBSTR(type, member, value, expect_str)
 
#define check_VariantToPropVariant(var, propvar, type, member, value, format)
 
#define check_PropVariantToVariant(propvar, var, type, member, value, format)
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
 DEFINE_GUID (dummy_guid, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe)
 
 DEFINE_GUID (expect_guid, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12)
 
 DEFINE_GUID (PKEY_WineTest, 0x7b317433, 0xdfa3, 0x4c44, 0xad, 0x3e, 0x2f, 0x80, 0x4b, 0x90, 0xdb, 0xf4)
 
 DEFINE_GUID (DUMMY_GUID1, 0x12345678, 0x1234, 0x1234, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19)
 
static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static void test_PSStringFromPropertyKey (void)
 
static void test_PSPropertyKeyFromString (void)
 
static void test_PSRefreshPropertySchema (void)
 
static void test_InitPropVariantFromGUIDAsString (void)
 
static void test_InitPropVariantFromBuffer (void)
 
static void test_PropVariantToGUID (void)
 
static void test_PropVariantToStringAlloc (void)
 
static void test_PropVariantCompareEx (void)
 
static void test_intconversions (void)
 
static void test_PropVariantToBoolean (void)
 
static void test_PropVariantToStringWithDefault (void)
 
static void test_PropVariantChangeType_LPWSTR (void)
 
static void test_InitPropVariantFromCLSID (void)
 
static void test_InitPropVariantFromStringVector (void)
 
static void test_PropVariantToDouble (void)
 
static void test_PropVariantToString (void)
 
static void test_PropVariantToBSTR (void)
 
static void test_PropVariantToBuffer (void)
 
static void test_inmemorystore (void)
 
static void test_persistserialized (void)
 
static void test_PSCreateMemoryPropertyStore (void)
 
static void test_propertystore (void)
 
static void test_PSCreatePropertyStoreFromObject (void)
 
static void test_InitVariantFromFileTime (void)
 
static void test_VariantToStringWithDefault (void)
 
static void test_VariantToString (void)
 
static void test_VariantToPropVariant (void)
 
static void test_PropVariantToVariant (void)
 
 START_TEST (propsys)
 

Variables

static const char topic [] = "wine topic"
 
static const WCHAR topicW [] = {'w','i','n','e',' ','t','o','p','i','c',0}
 
static const WCHAR emptyW [] = {0}
 
static const WCHAR dummy_guid_str [] = L"{DEADBEEF-DEAD-BEEF-DEAD-BEEFCAFEBABE}"
 

Macro Definition Documentation

◆ check_PropVariantToBSTR

#define check_PropVariantToBSTR (   type,
  member,
  value,
  expect_str 
)
Value:
do \
{ \
PROPVARIANT check_propvar_ = {.vt = (type), .member = (value)}; \
HRESULT check_hr_; \
BSTR check_bstr_; \
\
check_hr_ = PropVariantToBSTR(&check_propvar_, &check_bstr_); \
ok_(__FILE__, __LINE__)(check_hr_ == S_OK, \
"PropVariantToBSTR returned %#lx.\n", check_hr_); \
\
if (check_hr_ == S_OK) \
{ \
ok_(__FILE__, __LINE__)(!wcscmp(check_bstr_, (expect_str)), \
"Unexpected bstr %s.\n", debugstr_w(check_bstr_)); \
SysFreeString(check_bstr_); \
} \
} while (0)
#define expect_str(obj, str)
Definition: autocomplete.c:215
OLECHAR * BSTR
Definition: compat.h:2293
HRESULT WINAPI PropVariantToBSTR(REFPROPVARIANT propvar, BSTR *bstr)
Definition: propvar.c:338
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
#define debugstr_w
Definition: kernel32.h:32
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: pdh_main.c:94

Definition at line 1635 of file propsys.c.

◆ check_PropVariantToVariant

#define check_PropVariantToVariant (   propvar,
  var,
  type,
  member,
  value,
  format 
)
Value:
do \
{ \
(propvar).vt = VT_##type; \
(propvar).member = (value); \
hr = PropVariantToVariant(&(propvar), &(var)); \
ok_(__FILE__, __LINE__)(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr); \
ok_(__FILE__, __LINE__)(V_VT(&(var)) == VT_##type, "Unexpected vt %d.\n", V_VT(&(var))); \
ok_(__FILE__, __LINE__)(V_##type(&(var)) == (value), \
"Unexpected V_"#type"(&var) "format".\n", (propvar).member); \
} while (0)
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
HRESULT WINAPI PropVariantToVariant(const PROPVARIANT *propvar, VARIANT *var)
Definition: propvar.c:1073
const char * var
Definition: shader.c:5666
#define V_VT(A)
Definition: oleauto.h:211
HRESULT hr
Definition: shlfolder.c:183
Definition: format.c:58

Definition at line 2470 of file propsys.c.

◆ check_VariantToPropVariant

#define check_VariantToPropVariant (   var,
  propvar,
  type,
  member,
  value,
  format 
)
Value:
do \
{ \
V_VT(&(var)) = VT_##type; \
V_##type(&(var)) = (value); \
hr = VariantToPropVariant(&(var), &(propvar)); \
ok_(__FILE__, __LINE__)(hr == S_OK, "VariantToPropVariant returned %#lx.\n", hr); \
ok_(__FILE__, __LINE__)((propvar).vt == VT_##type, "Unexpected propvar.vt %d.\n", (propvar).vt); \
ok_(__FILE__, __LINE__)((propvar).member == (value), \
"Unexpected propvar."#member" "format".\n", (propvar).member); \
} while (0)
HRESULT WINAPI VariantToPropVariant(const VARIANT *var, PROPVARIANT *propvar)
Definition: propvar.c:1146

Definition at line 2459 of file propsys.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file propsys.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown *)obj, ref, __LINE__)

Definition at line 50 of file propsys.c.

◆ GUID_MEMBERS

#define GUID_MEMBERS (   g)    {(g).Data1, (g).Data2, (g).Data3, {(g).Data4[0], (g).Data4[1], (g).Data4[2], (g).Data4[3], (g).Data4[4], (g).Data4[5], (g).Data4[6], (g).Data4[7]}}

Definition at line 43 of file propsys.c.

Function Documentation

◆ _expect_ref()

static void _expect_ref ( IUnknown obj,
ULONG  ref,
int  line 
)
static

Definition at line 51 of file propsys.c.

52{
53 ULONG rc;
54 IUnknown_AddRef(obj);
55 rc = IUnknown_Release(obj);
56 ok_(__FILE__,line)(rc == ref, "expected refcount %ld, got %ld\n", ref, rc);
57}
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: parser.c:49
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ DEFINE_GUID() [1/5]

DEFINE_GUID ( dummy_guid  ,
0xdeadbeef  ,
0xdead  ,
0xbeef  ,
0xde  ,
0xad  ,
0xbe  ,
0xef  ,
0xca  ,
0xfe  ,
0xba  ,
0xbe   
)

◆ DEFINE_GUID() [2/5]

DEFINE_GUID ( DUMMY_GUID1  ,
0x12345678  ,
0x1234  ,
0x1234  ,
0x12  ,
0x13  ,
0x14  ,
0x15  ,
0x16  ,
0x17  ,
0x18  ,
0x19   
)

◆ DEFINE_GUID() [3/5]

DEFINE_GUID ( expect_guid  ,
0x12345678  ,
0x1234  ,
0x1234  ,
0x12  ,
0x34  ,
0x12  ,
0x34  ,
0x56  ,
0x78  ,
0x90  ,
0x12   
)

◆ DEFINE_GUID() [4/5]

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ DEFINE_GUID() [5/5]

DEFINE_GUID ( PKEY_WineTest  ,
0x7b317433  ,
0xdfa3  ,
0x4c44  ,
0xad  ,
0x3e  ,
0x2f  ,
0x80  ,
0x4b  ,
0x90  ,
0xdb  ,
0xf4   
)

◆ START_TEST()

START_TEST ( propsys  )

Definition at line 2629 of file propsys.c.

2630{
2636
2660}
static void test_VariantToString(void)
Definition: propsys.c:2423
static void test_InitPropVariantFromStringVector(void)
Definition: propsys.c:1442
static void test_PSRefreshPropertySchema(void)
Definition: propsys.c:447
static void test_inmemorystore(void)
Definition: propsys.c:1845
static void test_PropVariantToBuffer(void)
Definition: propsys.c:1737
static void test_PSCreatePropertyStoreFromObject(void)
Definition: propsys.c:2171
static void test_propertystore(void)
Definition: propsys.c:2113
static void test_InitVariantFromFileTime(void)
Definition: propsys.c:2203
static void test_PropVariantToStringWithDefault(void)
Definition: propsys.c:1283
static void test_intconversions(void)
Definition: propsys.c:943
static void test_InitPropVariantFromCLSID(void)
Definition: propsys.c:1424
static void test_InitPropVariantFromGUIDAsString(void)
Definition: propsys.c:465
static void test_PSPropertyKeyFromString(void)
Definition: propsys.c:162
static void test_PropVariantToBSTR(void)
Definition: propsys.c:1654
static void test_VariantToPropVariant(void)
Definition: propsys.c:2481
static void test_PropVariantToVariant(void)
Definition: propsys.c:2544
static void test_PropVariantToBoolean(void)
Definition: propsys.c:1072
static void test_PropVariantToString(void)
Definition: propsys.c:1527
static void test_PropVariantCompareEx(void)
Definition: propsys.c:675
static void test_VariantToStringWithDefault(void)
Definition: propsys.c:2237
static void test_InitPropVariantFromBuffer(void)
Definition: propsys.c:513
static void test_PropVariantChangeType_LPWSTR(void)
Definition: propsys.c:1388
static void test_persistserialized(void)
Definition: propsys.c:2011
static void test_PSStringFromPropertyKey(void)
Definition: propsys.c:59
static void test_PropVariantToGUID(void)
Definition: propsys.c:567
static void test_PropVariantToStringAlloc(void)
Definition: propsys.c:640
static void test_PropVariantToDouble(void)
Definition: propsys.c:1471
static void test_PSCreateMemoryPropertyStore(void)
Definition: propsys.c:2069

◆ test_InitPropVariantFromBuffer()

static void test_InitPropVariantFromBuffer ( void  )
static

Definition at line 513 of file propsys.c.

514{
515 static const char data_in[] = "test";
516 PROPVARIANT propvar;
517 VARIANT var;
519 void *data_out;
520 LONG size;
521
522 hres = InitPropVariantFromBuffer(NULL, 0, &propvar);
523 ok(hres == S_OK, "InitPropVariantFromBuffer returned %lx\n", hres);
524 ok(propvar.vt == (VT_VECTOR|VT_UI1), "propvar.vt = %d\n", propvar.vt);
525 ok(propvar.caub.cElems == 0, "cElems = %d\n", propvar.caub.cElems == 0);
526 PropVariantClear(&propvar);
527
528 hres = InitPropVariantFromBuffer(data_in, 4, &propvar);
529 ok(hres == S_OK, "InitPropVariantFromBuffer returned %lx\n", hres);
530 ok(propvar.vt == (VT_VECTOR|VT_UI1), "propvar.vt = %d\n", propvar.vt);
531 ok(propvar.caub.cElems == 4, "cElems = %d\n", propvar.caub.cElems == 0);
532 ok(!memcmp(propvar.caub.pElems, data_in, 4), "Data inside array is incorrect\n");
533 PropVariantClear(&propvar);
534
536 ok(hres == S_OK, "InitVariantFromBuffer returned %lx\n", hres);
537 ok(V_VT(&var) == (VT_ARRAY|VT_UI1), "V_VT(&var) = %d\n", V_VT(&var));
539 ok(size == 1, "SafeArrayGetDim returned %ld\n", size);
541 ok(hres == S_OK, "SafeArrayGetLBound returned %lx\n", hres);
542 ok(size == 0, "LBound = %ld\n", size);
544 ok(hres == S_OK, "SafeArrayGetUBound returned %lx\n", hres);
545 ok(size == -1, "UBound = %ld\n", size);
547
548 hres = InitVariantFromBuffer(data_in, 4, &var);
549 ok(hres == S_OK, "InitVariantFromBuffer returned %lx\n", hres);
550 ok(V_VT(&var) == (VT_ARRAY|VT_UI1), "V_VT(&var) = %d\n", V_VT(&var));
552 ok(size == 1, "SafeArrayGetDim returned %ld\n", size);
554 ok(hres == S_OK, "SafeArrayGetLBound returned %lx\n", hres);
555 ok(size == 0, "LBound = %ld\n", size);
557 ok(hres == S_OK, "SafeArrayGetUBound returned %lx\n", hres);
558 ok(size == 3, "UBound = %ld\n", size);
559 hres = SafeArrayAccessData(V_ARRAY(&var), &data_out);
560 ok(hres == S_OK, "SafeArrayAccessData failed %lx\n", hres);
561 ok(!memcmp(data_in, data_out, 4), "Data inside safe array is incorrect\n");
563 ok(hres == S_OK, "SafeArrayUnaccessData failed %lx\n", hres);
565}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT InitVariantFromBuffer(const void *buffer, UINT cb, VARIANT *pv)
Definition: util.h:26
@ VT_ARRAY
Definition: compat.h:2341
@ VT_VECTOR
Definition: compat.h:2340
@ VT_UI1
Definition: compat.h:2311
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2968
HRESULT WINAPI SafeArrayGetUBound(SAFEARRAY *psa, UINT nDim, LONG *plUbound)
Definition: safearray.c:1033
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
UINT WINAPI SafeArrayGetDim(SAFEARRAY *psa)
Definition: safearray.c:1094
HRESULT WINAPI SafeArrayGetLBound(SAFEARRAY *psa, UINT nDim, LONG *plLbound)
Definition: safearray.c:1066
HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
Definition: propvar.c:723
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
#define V_ARRAY(A)
Definition: oleauto.h:222
long LONG
Definition: pedump.c:60
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648

Referenced by START_TEST().

◆ test_InitPropVariantFromCLSID()

static void test_InitPropVariantFromCLSID ( void  )
static

Definition at line 1424 of file propsys.c.

1425{
1426 PROPVARIANT propvar;
1427 GUID clsid;
1428 HRESULT hr;
1429
1430 memset(&propvar, 0, sizeof(propvar));
1431 propvar.vt = VT_I4;
1432 propvar.lVal = 15;
1433
1434 memset(&clsid, 0xcc, sizeof(clsid));
1435 hr = InitPropVariantFromCLSID(&clsid, &propvar);
1436 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1437 ok(propvar.vt == VT_CLSID, "Unexpected type %d.\n", propvar.vt);
1438 ok(IsEqualGUID(propvar.puuid, &clsid), "Unexpected puuid value.\n");
1439 PropVariantClear(&propvar);
1440}
@ VT_CLSID
Definition: compat.h:2337
@ VT_I4
Definition: compat.h:2298
HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar)
Definition: propvar.c:737
REFCLSID clsid
Definition: msctf.c:82
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_InitPropVariantFromGUIDAsString()

static void test_InitPropVariantFromGUIDAsString ( void  )
static

Definition at line 465 of file propsys.c.

466{
467 PROPVARIANT propvar;
468 VARIANT var;
470 int i;
471
472 const struct {
474 const WCHAR *str;
475 } testcases[] = {
476 {&IID_NULL, L"{00000000-0000-0000-0000-000000000000}" },
477 {&dummy_guid, dummy_guid_str },
478 };
479
481 ok(hres == E_FAIL, "InitPropVariantFromGUIDAsString returned %lx\n", hres);
482
483 if(0) {
484 /* Returns strange data on Win7, crashes on older systems */
486
487 /* Crashes on windows */
490 }
491
492 for(i=0; i < ARRAY_SIZE(testcases); i++) {
493 memset(&propvar, 0, sizeof(PROPVARIANT));
494 hres = InitPropVariantFromGUIDAsString(testcases[i].guid, &propvar);
495 ok(hres == S_OK, "%d) InitPropVariantFromGUIDAsString returned %lx\n", i, hres);
496 ok(propvar.vt == VT_LPWSTR, "%d) propvar.vt = %d\n", i, propvar.vt);
497 ok(!lstrcmpW(propvar.pwszVal, testcases[i].str), "%d) propvar.pwszVal = %s\n",
498 i, wine_dbgstr_w(propvar.pwszVal));
499 CoTaskMemFree(propvar.pwszVal);
500
501 memset(&var, 0, sizeof(VARIANT));
502 hres = InitVariantFromGUIDAsString(testcases[i].guid, &var);
503 ok(hres == S_OK, "%d) InitVariantFromGUIDAsString returned %lx\n", i, hres);
504 ok(V_VT(&var) == VT_BSTR, "%d) V_VT(&var) = %d\n", i, V_VT(&var));
505 ok(SysStringLen(V_BSTR(&var)) == 38, "SysStringLen returned %d\n",
507 ok(!lstrcmpW(V_BSTR(&var), testcases[i].str), "%d) V_BSTR(&var) = %s\n",
510 }
511}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_FAIL
Definition: ddrawi.h:102
@ VT_BSTR
Definition: compat.h:2303
@ VT_LPWSTR
Definition: compat.h:2325
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar)
Definition: propvar.c:705
HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar)
Definition: propvar.c:689
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define wine_dbgstr_w
Definition: kernel32.h:34
const GUID * guid
#define L(x)
Definition: ntvdm.h:50
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
#define V_BSTR(A)
Definition: oleauto.h:226
static const WCHAR dummy_guid_str[]
Definition: propsys.c:48
#define IID_NULL
Definition: guiddef.h:98
const WCHAR * str
Definition: scsiwmi.h:51
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_InitPropVariantFromStringVector()

static void test_InitPropVariantFromStringVector ( void  )
static

Definition at line 1442 of file propsys.c.

1443{
1444 static const WCHAR *strs[2] = { L"abc", L"def" };
1445 PROPVARIANT propvar;
1446 HRESULT hr;
1447
1448 memset(&propvar, 0, sizeof(propvar));
1449 propvar.vt = VT_I4;
1450 propvar.lVal = 15;
1451
1452 hr = InitPropVariantFromStringVector(NULL, 0, &propvar);
1453 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1454 ok(propvar.vt == (VT_LPWSTR|VT_VECTOR), "Unexpected type %#x.\n", propvar.vt);
1455 ok(!propvar.calpwstr.cElems, "Unexpected number of elements.\n");
1456 ok(!!propvar.calpwstr.pElems, "Unexpected vector pointer.\n");
1457 PropVariantClear(&propvar);
1458
1459 hr = InitPropVariantFromStringVector(strs, 2, &propvar);
1460 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1461 ok(propvar.vt == (VT_LPWSTR|VT_VECTOR), "Unexpected type %#x.\n", propvar.vt);
1462 ok(propvar.calpwstr.cElems == 2, "Unexpected number of elements.\n");
1463 ok(!!propvar.calpwstr.pElems, "Unexpected vector pointer.\n");
1464 ok(propvar.calpwstr.pElems[0] != strs[0], "Unexpected string pointer.\n");
1465 ok(!wcscmp(propvar.calpwstr.pElems[0], strs[0]), "Unexpected string %s.\n", debugstr_w(propvar.calpwstr.pElems[0]));
1466 ok(propvar.calpwstr.pElems[1] != strs[1], "Unexpected string pointer.\n");
1467 ok(!wcscmp(propvar.calpwstr.pElems[1], strs[1]), "Unexpected string %s.\n", debugstr_w(propvar.calpwstr.pElems[1]));
1468 PropVariantClear(&propvar);
1469}
HRESULT WINAPI InitPropVariantFromStringVector(PCWSTR *strs, ULONG count, PROPVARIANT *ppropvar)
Definition: propvar.c:750

Referenced by START_TEST().

◆ test_InitVariantFromFileTime()

static void test_InitVariantFromFileTime ( void  )
static

Definition at line 2203 of file propsys.c.

2204{
2205 FILETIME ft = {0};
2206 SYSTEMTIME st;
2207 VARIANT var;
2208 HRESULT hr;
2209 double d;
2210
2211 VariantInit(&var);
2212 if (0) /* crash on Windows */
2213 {
2216 }
2217
2218 ft.dwHighDateTime = -1;
2219 ft.dwLowDateTime = -1;
2220 V_VT(&var) = 0xdead;
2221 V_DATE(&var) = 42.0;
2223 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2224 ok(V_VT(&var) == VT_EMPTY, "Unexpected VT %d\n", V_VT(&var));
2225 ok(V_DATE(&var) == 0.0, "got wrong value: %f, expected 0.0\n", V_DATE(&var));
2226
2229 ok(V_VT(&var) == VT_DATE, "Unexpected VT %d\n", V_VT(&var));
2230 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2231
2232 FileTimeToSystemTime(&ft, &st);
2234 ok(V_DATE(&var) == d, "got wrong value: %f, expected %f\n", V_DATE(&var), d);
2235}
#define E_INVALIDARG
Definition: ddrawi.h:101
@ VT_DATE
Definition: compat.h:2302
@ VT_EMPTY
Definition: compat.h:2295
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
HRESULT WINAPI InitVariantFromFileTime(const FILETIME *ft, VARIANT *var)
Definition: propvar.c:813
#define d
Definition: ke_i.h:81
#define V_DATE(A)
Definition: oleauto.h:231
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
Definition: variant.c:1286

Referenced by START_TEST().

◆ test_inmemorystore()

static void test_inmemorystore ( void  )
static

Definition at line 1845 of file propsys.c.

1846{
1847 IPropertyStoreCache *propcache;
1848 HRESULT hr;
1849 PROPERTYKEY pkey;
1850 PROPVARIANT propvar;
1851 DWORD count;
1852 PSC_STATE state;
1853
1855
1856 hr = CoCreateInstance(&CLSID_InMemoryPropertyStore, NULL, CLSCTX_INPROC_SERVER,
1857 &IID_IPropertyStoreCache, (void**)&propcache);
1858 ok(hr == S_OK, "CoCreateInstance failed, hr=%lx\n", hr);
1859
1860 if (FAILED(hr))
1861 {
1862 win_skip("CLSID_InMemoryPropertyStore not supported\n");
1864 return;
1865 }
1866
1867 hr = IPropertyStoreCache_GetCount(propcache, NULL);
1868 ok(hr == E_POINTER, "GetCount failed, hr=%lx\n", hr);
1869
1870 hr = IPropertyStoreCache_GetCount(propcache, &count);
1871 ok(hr == S_OK, "GetCount failed, hr=%lx\n", hr);
1872 ok(count == 0, "GetCount returned %li, expected 0\n", count);
1873
1874 hr = IPropertyStoreCache_Commit(propcache);
1875 ok(hr == S_OK, "Commit failed, hr=%lx\n", hr);
1876
1877 hr = IPropertyStoreCache_Commit(propcache);
1878 ok(hr == S_OK, "Commit failed, hr=%lx\n", hr);
1879
1880 hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey);
1881 ok(hr == E_INVALIDARG, "GetAt failed, hr=%lx\n", hr);
1882
1883 pkey.fmtid = PKEY_WineTest;
1884 pkey.pid = 4;
1885
1886 memset(&propvar, 0, sizeof(propvar));
1887 propvar.vt = VT_I4;
1888 propvar.lVal = 12345;
1889
1890 if (0)
1891 {
1892 /* Crashes on Windows 7 */
1893 hr = IPropertyStoreCache_SetValue(propcache, NULL, &propvar);
1894 ok(hr == E_POINTER, "SetValue failed, hr=%lx\n", hr);
1895
1896 hr = IPropertyStoreCache_SetValue(propcache, &pkey, NULL);
1897 ok(hr == E_POINTER, "SetValue failed, hr=%lx\n", hr);
1898 }
1899
1900 hr = IPropertyStoreCache_SetValue(propcache, &pkey, &propvar);
1901 ok(hr == S_OK, "SetValue failed, hr=%lx\n", hr);
1902
1903 hr = IPropertyStoreCache_GetCount(propcache, &count);
1904 ok(hr == S_OK, "GetCount failed, hr=%lx\n", hr);
1905 ok(count == 1, "GetCount returned %li, expected 0\n", count);
1906
1907 memset(&pkey, 0, sizeof(pkey));
1908
1909 hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey);
1910 ok(hr == S_OK, "GetAt failed, hr=%lx\n", hr);
1911 ok(IsEqualGUID(&pkey.fmtid, &PKEY_WineTest), "got wrong pkey\n");
1912 ok(pkey.pid == 4, "got pid of %li, expected 4\n", pkey.pid);
1913
1914 pkey.fmtid = PKEY_WineTest;
1915 pkey.pid = 4;
1916
1917 memset(&propvar, 0, sizeof(propvar));
1918
1919 if (0)
1920 {
1921 /* Crashes on Windows 7 */
1922 hr = IPropertyStoreCache_GetValue(propcache, NULL, &propvar);
1923 ok(hr == E_POINTER, "GetValue failed, hr=%lx\n", hr);
1924 }
1925
1926 hr = IPropertyStoreCache_GetValue(propcache, &pkey, NULL);
1927 ok(hr == E_POINTER, "GetValue failed, hr=%lx\n", hr);
1928
1929 hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
1930 ok(hr == S_OK, "GetValue failed, hr=%lx\n", hr);
1931 ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
1932 ok(propvar.lVal == 12345, "expected 12345, got %ld\n", propvar.lVal);
1933
1934 pkey.fmtid = PKEY_WineTest;
1935 pkey.pid = 10;
1936
1937 /* Get information for field that isn't set yet */
1938 propvar.vt = VT_I2;
1939 hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
1940 ok(hr == S_OK, "GetValue failed, hr=%lx\n", hr);
1941 ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
1942
1943 state = 0xdeadbeef;
1944 hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
1945 ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetState failed, hr=%lx\n", hr);
1946 ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
1947
1948 propvar.vt = VT_I2;
1949 state = 0xdeadbeef;
1950 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
1951 ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetValueAndState failed, hr=%lx\n", hr);
1952 ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
1953 ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
1954
1955 /* Set state on an unset field */
1956 hr = IPropertyStoreCache_SetState(propcache, &pkey, PSC_NORMAL);
1957 ok(hr == TYPE_E_ELEMENTNOTFOUND, "SetState failed, hr=%lx\n", hr);
1958
1959 /* Manipulate state on already set field */
1960 pkey.fmtid = PKEY_WineTest;
1961 pkey.pid = 4;
1962
1963 state = 0xdeadbeef;
1964 hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
1965 ok(hr == S_OK, "GetState failed, hr=%lx\n", hr);
1966 ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
1967
1968 hr = IPropertyStoreCache_SetState(propcache, &pkey, 10);
1969 ok(hr == S_OK, "SetState failed, hr=%lx\n", hr);
1970
1971 state = 0xdeadbeef;
1972 hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
1973 ok(hr == S_OK, "GetState failed, hr=%lx\n", hr);
1974 ok(state == 10, "expected 10, got %d\n", state);
1975
1976 propvar.vt = VT_I4;
1977 propvar.lVal = 12346;
1978 hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, 5);
1979 ok(hr == S_OK, "SetValueAndState failed, hr=%lx\n", hr);
1980
1981 memset(&propvar, 0, sizeof(propvar));
1982 state = 0xdeadbeef;
1983 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
1984 ok(hr == S_OK, "GetValueAndState failed, hr=%lx\n", hr);
1985 ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
1986 ok(propvar.lVal == 12346, "expected 12346, got %d\n", propvar.vt);
1987 ok(state == 5, "expected 5, got %d\n", state);
1988
1989 /* Set new field with state */
1990 pkey.fmtid = PKEY_WineTest;
1991 pkey.pid = 8;
1992
1993 propvar.vt = VT_I4;
1994 propvar.lVal = 12347;
1995 hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, PSC_DIRTY);
1996 ok(hr == S_OK, "SetValueAndState failed, hr=%lx\n", hr);
1997
1998 memset(&propvar, 0, sizeof(propvar));
1999 state = 0xdeadbeef;
2000 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
2001 ok(hr == S_OK, "GetValueAndState failed, hr=%lx\n", hr);
2002 ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
2003 ok(propvar.lVal == 12347, "expected 12347, got %d\n", propvar.vt);
2004 ok(state == PSC_DIRTY, "expected PSC_DIRTY, got %d\n", state);
2005
2006 IPropertyStoreCache_Release(propcache);
2007
2009}
static int state
Definition: maze.c:121
@ VT_I2
Definition: compat.h:2297
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
#define win_skip
Definition: test.h:163
#define TYPE_E_ELEMENTNOTFOUND
Definition: winerror.h:2539
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_intconversions()

static void test_intconversions ( void  )
static

Definition at line 943 of file propsys.c.

944{
945 PROPVARIANT propvar;
946 SHORT sval;
947 USHORT usval;
948 LONG lval;
949 ULONG ulval;
951 ULONGLONG ullval;
952 HRESULT hr;
953
954 propvar.vt = 0xdead;
955 hr = PropVariantClear(&propvar);
956 ok (FAILED(hr), "PropVariantClear fails on invalid vt.\n");
957
958 propvar.vt = VT_I8;
959 PropVariantClear(&propvar);
960
961 propvar.vt = VT_I8;
962 propvar.hVal.QuadPart = (ULONGLONG)1 << 63;
963
964 hr = PropVariantToInt64(&propvar, &llval);
965 ok(hr == S_OK, "hr=%lx\n", hr);
966 ok(llval == (ULONGLONG)1 << 63, "got wrong value %s\n", wine_dbgstr_longlong(llval));
967
968 hr = PropVariantToUInt64(&propvar, &ullval);
970
971 hr = PropVariantToInt32(&propvar, &lval);
973
974 hr = PropVariantToUInt32(&propvar, &ulval);
976
977 ulval = PropVariantToUInt32WithDefault(&propvar, 77);
978 ok(ulval == 77, "ulval=%lu\n", ulval);
979
980 hr = PropVariantToInt16(&propvar, &sval);
982
983 hr = PropVariantToUInt16(&propvar, &usval);
985
986 propvar.vt = VT_UI8;
987 propvar.uhVal.QuadPart = 5;
988
989 hr = PropVariantToInt64(&propvar, &llval);
990 ok(hr == S_OK, "hr=%lx\n", hr);
991 ok(llval == 5, "got wrong value %s\n", wine_dbgstr_longlong(llval));
992
993 hr = PropVariantToUInt64(&propvar, &ullval);
994 ok(hr == S_OK, "hr=%lx\n", hr);
995 ok(ullval == 5, "got wrong value %s\n", wine_dbgstr_longlong(ullval));
996
997 hr = PropVariantToInt32(&propvar, &lval);
998 ok(hr == S_OK, "hr=%lx\n", hr);
999 ok(lval == 5, "got wrong value %ld\n", lval);
1000
1001 hr = PropVariantToUInt32(&propvar, &ulval);
1002 ok(hr == S_OK, "hr=%lx\n", hr);
1003 ok(ulval == 5, "got wrong value %ld\n", ulval);
1004
1005 ulval = PropVariantToUInt32WithDefault(&propvar, 77);
1006 ok(ulval == 5, "got wrong value %lu\n", ulval);
1007
1008 hr = PropVariantToInt16(&propvar, &sval);
1009 ok(hr == S_OK, "hr=%lx\n", hr);
1010 ok(sval == 5, "got wrong value %d\n", sval);
1011
1012 hr = PropVariantToUInt16(&propvar, &usval);
1013 ok(hr == S_OK, "hr=%lx\n", hr);
1014 ok(usval == 5, "got wrong value %d\n", usval);
1015
1016 propvar.vt = VT_I8;
1017 propvar.hVal.QuadPart = -5;
1018
1019 hr = PropVariantToInt64(&propvar, &llval);
1020 ok(hr == S_OK, "hr=%lx\n", hr);
1021 ok(llval == -5, "got wrong value %s\n", wine_dbgstr_longlong(llval));
1022
1023 hr = PropVariantToUInt64(&propvar, &ullval);
1025
1026 hr = PropVariantToInt32(&propvar, &lval);
1027 ok(hr == S_OK, "hr=%lx\n", hr);
1028 ok(lval == -5, "got wrong value %ld\n", lval);
1029
1030 hr = PropVariantToUInt32(&propvar, &ulval);
1032
1033 ulval = PropVariantToUInt32WithDefault(&propvar, 77);
1034 ok(ulval == 77, "ulval=%lu\n", ulval);
1035
1036 hr = PropVariantToInt16(&propvar, &sval);
1037 ok(hr == S_OK, "hr=%lx\n", hr);
1038 ok(sval == -5, "got wrong value %d\n", sval);
1039
1040 hr = PropVariantToUInt16(&propvar, &usval);
1042
1043 propvar.vt = VT_UI4;
1044 propvar.ulVal = 6;
1045
1046 hr = PropVariantToInt64(&propvar, &llval);
1047 ok(hr == S_OK, "hr=%lx\n", hr);
1048 ok(llval == 6, "got wrong value %s\n", wine_dbgstr_longlong(llval));
1049
1050 propvar.vt = VT_I4;
1051 propvar.lVal = -6;
1052
1053 hr = PropVariantToInt64(&propvar, &llval);
1054 ok(hr == S_OK, "hr=%lx\n", hr);
1055 ok(llval == -6, "got wrong value %s\n", wine_dbgstr_longlong(llval));
1056
1057 propvar.vt = VT_UI2;
1058 propvar.uiVal = 7;
1059
1060 hr = PropVariantToInt64(&propvar, &llval);
1061 ok(hr == S_OK, "hr=%lx\n", hr);
1062 ok(llval == 7, "got wrong value %s\n", wine_dbgstr_longlong(llval));
1063
1064 propvar.vt = VT_I2;
1065 propvar.iVal = -7;
1066
1067 hr = PropVariantToInt64(&propvar, &llval);
1068 ok(hr == S_OK, "hr=%lx\n", hr);
1069 ok(llval == -7, "got wrong value %s\n", wine_dbgstr_longlong(llval));
1070}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
@ VT_UI8
Definition: compat.h:2315
@ VT_UI2
Definition: compat.h:2312
@ VT_I8
Definition: compat.h:2314
@ VT_UI4
Definition: compat.h:2313
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
Definition: propvar.c:208
ULONG WINAPI PropVariantToUInt32WithDefault(REFPROPVARIANT propvarIn, ULONG ulDefault)
Definition: propvar.c:256
HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
Definition: propvar.c:232
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
Definition: propvar.c:220
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
Definition: propvar.c:270
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
Definition: propvar.c:244
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
Definition: propvar.c:196
short SHORT
Definition: pedump.c:59
unsigned short USHORT
Definition: pedump.c:61
Llong llval
Definition: format.c:276
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_ARITHMETIC_OVERFLOW
Definition: winerror.h:351

Referenced by START_TEST().

◆ test_persistserialized()

static void test_persistserialized ( void  )
static

Definition at line 2011 of file propsys.c.

2012{
2013 IPropertyStore *propstore;
2015 HRESULT hr;
2018
2020
2021 hr = CoCreateInstance(&CLSID_InMemoryPropertyStore, NULL, CLSCTX_INPROC_SERVER,
2022 &IID_IPropertyStore, (void**)&propstore);
2023 ok(hr == S_OK, "CoCreateInstance failed, hr=%lx\n", hr);
2024
2025 hr = IPropertyStore_QueryInterface(propstore, &IID_IPersistSerializedPropStorage,
2026 (void**)&serialized);
2027 todo_wine ok(hr == S_OK, "QueryInterface failed, hr=%lx\n", hr);
2028
2029 if (FAILED(hr))
2030 {
2031 IPropertyStore_Release(propstore);
2032 skip("IPersistSerializedPropStorage not supported\n");
2034 return;
2035 }
2036
2037 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized, NULL, &result_size);
2038 ok(hr == E_POINTER, "GetPropertyStorage failed, hr=%lx\n", hr);
2039
2040 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized, &result, NULL);
2041 ok(hr == E_POINTER, "GetPropertyStorage failed, hr=%lx\n", hr);
2042
2043 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized, &result, &result_size);
2044 ok(hr == S_OK, "GetPropertyStorage failed, hr=%lx\n", hr);
2045
2046 if (SUCCEEDED(hr))
2047 {
2048 ok(result_size == 0, "expected 0 bytes, got %li\n", result_size);
2049
2051 }
2052
2053 hr = IPersistSerializedPropStorage_SetPropertyStorage(serialized, NULL, 4);
2054 ok(hr == E_POINTER, "SetPropertyStorage failed, hr=%lx\n", hr);
2055
2056 hr = IPersistSerializedPropStorage_SetPropertyStorage(serialized, NULL, 0);
2057 ok(hr == S_OK, "SetPropertyStorage failed, hr=%lx\n", hr);
2058
2059 hr = IPropertyStore_GetCount(propstore, &result_size);
2060 ok(hr == S_OK, "GetCount failed, hr=%lx\n", hr);
2061 ok(result_size == 0, "expecting 0, got %ld\n", result_size);
2062
2063 IPropertyStore_Release(propstore);
2064 IPersistSerializedPropStorage_Release(serialized);
2065
2067}
PCWSTR const LCTYPE const int const result_size
#define skip(...)
Definition: atltest.h:64
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define todo_wine
Definition: custom.c:89
struct tagSERIALIZEDROPSTORAGE SERIALIZEDPROPSTORAGE
Definition: propsys.idl:733

Referenced by START_TEST().

◆ test_propertystore()

static void test_propertystore ( void  )
static

Definition at line 2113 of file propsys.c.

2114{
2115 IPropertyStore *propstore;
2116 HRESULT hr;
2117 PROPVARIANT propvar, ret_propvar;
2118 PROPERTYKEY propkey;
2119 DWORD count = 0;
2120
2121 hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore);
2122 ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08lx.\n", hr);
2123 ok(propstore != NULL, "got %p.\n", propstore);
2124
2125 hr = IPropertyStore_GetCount(propstore, &count);
2126 ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08lx.\n", hr);
2127 ok(!count, "got wrong property count: %ld, expected 0.\n", count);
2128
2129 PropVariantInit(&propvar);
2130 propvar.vt = VT_I4;
2131 propvar.lVal = 123;
2132 propkey.fmtid = DUMMY_GUID1;
2133 propkey.pid = PID_FIRST_USABLE;
2134 hr = IPropertyStore_SetValue(propstore, &propkey, &propvar);
2135 ok(hr == S_OK, "IPropertyStore_SetValue failed: 0x%08lx.\n", hr);
2136 hr = IPropertyStore_Commit(propstore);
2137 ok(hr == S_OK, "IPropertyStore_Commit failed: 0x%08lx.\n", hr);
2138 hr = IPropertyStore_GetCount(propstore, &count);
2139 ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08lx.\n", hr);
2140 ok(count == 1, "got wrong property count: %ld, expected 1.\n", count);
2141 PropVariantInit(&ret_propvar);
2142 ret_propvar.vt = VT_I4;
2143 hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar);
2144 ok(hr == S_OK, "IPropertyStore_GetValue failed: 0x%08lx.\n", hr);
2145 ok(ret_propvar.vt == VT_I4, "got wrong property type: %x.\n", ret_propvar.vt);
2146 ok(ret_propvar.lVal == 123, "got wrong value: %ld, expected 123.\n", ret_propvar.lVal);
2147 PropVariantClear(&propvar);
2148 PropVariantClear(&ret_propvar);
2149
2150 PropVariantInit(&propvar);
2151 propkey.fmtid = DUMMY_GUID1;
2152 propkey.pid = PID_FIRST_USABLE;
2153 hr = IPropertyStore_SetValue(propstore, &propkey, &propvar);
2154 ok(hr == S_OK, "IPropertyStore_SetValue failed: 0x%08lx.\n", hr);
2155 hr = IPropertyStore_Commit(propstore);
2156 ok(hr == S_OK, "IPropertyStore_Commit failed: 0x%08lx.\n", hr);
2157 hr = IPropertyStore_GetCount(propstore, &count);
2158 ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08lx.\n", hr);
2159 ok(count == 1, "got wrong property count: %ld, expected 1.\n", count);
2160 PropVariantInit(&ret_propvar);
2161 hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar);
2162 ok(hr == S_OK, "IPropertyStore_GetValue failed: 0x%08lx.\n", hr);
2163 ok(ret_propvar.vt == VT_EMPTY, "got wrong property type: %x.\n", ret_propvar.vt);
2164 ok(!ret_propvar.lVal, "got wrong value: %ld, expected 0.\n", ret_propvar.lVal);
2165 PropVariantClear(&propvar);
2166 PropVariantClear(&ret_propvar);
2167
2168 IPropertyStore_Release(propstore);
2169}
#define PID_FIRST_USABLE
Definition: propkeydef.h:20
HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv)
Definition: propsys_main.c:471

Referenced by START_TEST().

◆ test_PropVariantChangeType_LPWSTR()

static void test_PropVariantChangeType_LPWSTR ( void  )
static

Definition at line 1388 of file propsys.c.

1389{
1390 PROPVARIANT dest, src;
1391 HRESULT hr;
1392
1393 PropVariantInit(&dest);
1394
1395 src.vt = VT_NULL;
1397 ok(hr == S_OK, "hr=%lx\n", hr);
1398 ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
1399 ok(!lstrcmpW(dest.pwszVal, emptyW), "got %s\n", wine_dbgstr_w(dest.pwszVal));
1402
1403 src.vt = VT_LPSTR;
1404 src.pszVal = CoTaskMemAlloc(strlen(topic)+1);
1405 strcpy(src.pszVal, topic);
1407 ok(hr == S_OK, "hr=%lx\n", hr);
1408 ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
1409 ok(!lstrcmpW(dest.pwszVal, topicW), "got %s\n", wine_dbgstr_w(dest.pwszVal));
1412
1413 src.vt = VT_LPWSTR;
1414 src.pwszVal = CoTaskMemAlloc( (lstrlenW(topicW)+1) * sizeof(WCHAR));
1415 lstrcpyW(src.pwszVal, topicW);
1417 ok(hr == S_OK, "hr=%lx\n", hr);
1418 ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
1419 ok(!lstrcmpW(dest.pwszVal, topicW), "got %s\n", wine_dbgstr_w(dest.pwszVal));
1422}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define lstrcpyW
Definition: compat.h:749
@ VT_LPSTR
Definition: compat.h:2324
@ VT_NULL
Definition: compat.h:2296
#define lstrlenW
Definition: compat.h:750
HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc, PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
Definition: propvar.c:537
GLenum src
Definition: glext.h:6340
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
static char * dest
Definition: rtl.c:135
static const WCHAR topicW[]
Definition: propsys.c:46
static const WCHAR emptyW[]
Definition: propsys.c:47
static const char topic[]
Definition: propsys.c:45
strcpy
Definition: string.h:131

Referenced by START_TEST().

◆ test_PropVariantCompareEx()

static void test_PropVariantCompareEx ( void  )
static

Definition at line 675 of file propsys.c.

676{
677 PROPVARIANT empty, null, emptyarray, i2_0, i2_2, i4_large, i4_largeneg, i4_2, str_2, str_02, str_b;
678 PROPVARIANT clsid_null, clsid, clsid2, r4_0, r4_2, r8_0, r8_2;
679 PROPVARIANT ui4, ui4_large;
680 PROPVARIANT var1, var2;
681 INT res;
682 static const WCHAR str_2W[] = {'2', 0};
683 static const WCHAR str_02W[] = {'0', '2', 0};
684 static const WCHAR str_bW[] = {'b', 0};
685 SAFEARRAY emptysafearray;
686 unsigned char bytevector1[] = {1,2,3};
687 unsigned char bytevector2[] = {4,5,6};
688
689 PropVariantInit(&empty);
690 PropVariantInit(&null);
691 PropVariantInit(&emptyarray);
692 PropVariantInit(&i2_0);
693 PropVariantInit(&i2_2);
694 PropVariantInit(&i4_large);
695 PropVariantInit(&i4_largeneg);
696 PropVariantInit(&i4_2);
697 PropVariantInit(&str_2);
698 PropVariantInit(&str_b);
699
700 empty.vt = VT_EMPTY;
701 null.vt = VT_NULL;
702 emptyarray.vt = VT_ARRAY | VT_I4;
703 emptyarray.parray = &emptysafearray;
704 emptysafearray.cDims = 1;
705 emptysafearray.fFeatures = FADF_FIXEDSIZE;
706 emptysafearray.cbElements = 4;
707 emptysafearray.cLocks = 0;
708 emptysafearray.pvData = NULL;
709 emptysafearray.rgsabound[0].cElements = 0;
710 emptysafearray.rgsabound[0].lLbound = 0;
711 i2_0.vt = VT_I2;
712 i2_0.iVal = 0;
713 i2_2.vt = VT_I2;
714 i2_2.iVal = 2;
715 i4_large.vt = VT_I4;
716 i4_large.lVal = 65536;
717 i4_largeneg.vt = VT_I4;
718 i4_largeneg.lVal = -65536;
719 i4_2.vt = VT_I4;
720 i4_2.lVal = 2;
721 ui4.vt = VT_UI4;
722 ui4.ulVal = 2;
723 ui4_large.vt = VT_UI4;
724 ui4_large.ulVal = 65536;
725 str_2.vt = VT_BSTR;
726 str_2.bstrVal = SysAllocString(str_2W);
727 str_02.vt = VT_BSTR;
728 str_02.bstrVal = SysAllocString(str_02W);
729 str_b.vt = VT_BSTR;
730 str_b.bstrVal = SysAllocString(str_bW);
731 clsid_null.vt = VT_CLSID;
732 clsid_null.puuid = NULL;
733 clsid.vt = VT_CLSID;
734 clsid.puuid = (GUID *)&dummy_guid;
735 clsid2.vt = VT_CLSID;
736 clsid2.puuid = (GUID *)&GUID_NULL;
737 r4_0.vt = VT_R4;
738 r4_0.fltVal = 0.0f;
739 r4_2.vt = VT_R4;
740 r4_2.fltVal = 2.0f;
741 r8_0.vt = VT_R8;
742 r8_0.dblVal = 0.0;
743 r8_2.vt = VT_R8;
744 r8_2.dblVal = 2.0;
745
747 ok(res == 0, "res=%i\n", res);
748
750 ok(res == 0, "res=%i\n", res);
751
752 res = PropVariantCompareEx(&null, &emptyarray, 0, 0);
753 ok(res == 0, "res=%i\n", res);
754
755 res = PropVariantCompareEx(&null, &i2_0, 0, 0);
756 ok(res == -1, "res=%i\n", res);
757
758 res = PropVariantCompareEx(&i2_0, &null, 0, 0);
759 ok(res == 1, "res=%i\n", res);
760
762 ok(res == 1, "res=%i\n", res);
763
765 ok(res == -1, "res=%i\n", res);
766
767 res = PropVariantCompareEx(&i2_2, &i2_0, 0, 0);
768 ok(res == 1, "res=%i\n", res);
769
770 res = PropVariantCompareEx(&i2_0, &i2_2, 0, 0);
771 ok(res == -1, "res=%i\n", res);
772
773 res = PropVariantCompareEx(&ui4, &ui4_large, 0, 0);
774 ok(res == -1, "res=%i\n", res);
775
776 res = PropVariantCompareEx(&ui4_large, &ui4, 0, 0);
777 ok(res == 1, "res=%i\n", res);
778
779 /* Always return -1 if second value cannot be converted to first type */
780 res = PropVariantCompareEx(&i2_0, &i4_large, 0, 0);
781 ok(res == -1, "res=%i\n", res);
782
783 res = PropVariantCompareEx(&i2_0, &i4_largeneg, 0, 0);
784 ok(res == -1, "res=%i\n", res);
785
786 res = PropVariantCompareEx(&i4_large, &i2_0, 0, 0);
787 ok(res == 1, "res=%i\n", res);
788
789 res = PropVariantCompareEx(&i4_largeneg, &i2_0, 0, 0);
790 ok(res == -1, "res=%i\n", res);
791
792 res = PropVariantCompareEx(&i2_2, &i4_2, 0, 0);
793 ok(res == 0, "res=%i\n", res);
794
795 res = PropVariantCompareEx(&i2_2, &str_2, 0, 0);
796 ok(res == 0, "res=%i\n", res);
797
798 res = PropVariantCompareEx(&i2_2, &str_02, 0, 0);
799 ok(res == 0, "res=%i\n", res);
800
801 res = PropVariantCompareEx(&str_2, &i2_2, 0, 0);
802 todo_wine ok(res == 0, "res=%i\n", res);
803
804 res = PropVariantCompareEx(&str_02, &i2_2, 0, 0);
805 ok(res == -1, "res=%i\n", res);
806
807 res = PropVariantCompareEx(&str_02, &str_2, 0, 0);
808 ok(res == -1, "res=%i\n", res);
809
810 res = PropVariantCompareEx(&str_02, &str_b, 0, 0);
811 ok(res == -1, "res=%i\n", res);
812
813 res = PropVariantCompareEx(&str_2, &str_02, 0, 0);
814 ok(res == 1, "res=%i\n", res);
815
816 res = PropVariantCompareEx(&i4_large, &str_b, 0, 0);
817 todo_wine ok(res == -5 /* ??? */, "res=%i\n", res);
818
819 /* VT_CLSID */
820 res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, 0);
821 ok(res == 0, "res=%i\n", res);
822
823 res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, PVCF_TREATEMPTYASGREATERTHAN);
824 ok(res == 0, "res=%i\n", res);
825
827 ok(res == 0, "res=%i\n", res);
828
829 res = PropVariantCompareEx(&clsid, &clsid2, 0, 0);
830 ok(res == 1, "res=%i\n", res);
831
832 res = PropVariantCompareEx(&clsid2, &clsid, 0, 0);
833 ok(res == -1, "res=%i\n", res);
834
835 res = PropVariantCompareEx(&clsid_null, &clsid, 0, 0);
836 ok(res == -1, "res=%i\n", res);
837
838 res = PropVariantCompareEx(&clsid, &clsid_null, 0, 0);
839 ok(res == 1, "res=%i\n", res);
840
842 ok(res == 1, "res=%i\n", res);
843
845 ok(res == -1, "res=%i\n", res);
846
847 /* VT_R4/VT_R8 */
848 res = PropVariantCompareEx(&r4_0, &r8_0, 0, 0);
850 ok(res == 0, "res=%i\n", res);
851
852 res = PropVariantCompareEx(&r4_0, &r4_0, 0, 0);
853 ok(res == 0, "res=%i\n", res);
854
855 res = PropVariantCompareEx(&r4_0, &r4_2, 0, 0);
856 ok(res == -1, "res=%i\n", res);
857
858 res = PropVariantCompareEx(&r4_2, &r4_0, 0, 0);
859 ok(res == 1, "res=%i\n", res);
860
861 res = PropVariantCompareEx(&r8_0, &r8_0, 0, 0);
862 ok(res == 0, "res=%i\n", res);
863
864 res = PropVariantCompareEx(&r8_0, &r8_2, 0, 0);
865 ok(res == -1, "res=%i\n", res);
866
867 res = PropVariantCompareEx(&r8_2, &r8_0, 0, 0);
868 ok(res == 1, "res=%i\n", res);
869
870 /* VT_VECTOR | VT_UI1 */
871 var1.vt = VT_VECTOR | VT_UI1;
872 var1.caub.cElems = 1;
873 var1.caub.pElems = bytevector1;
874 var2.vt = VT_VECTOR | VT_UI1;
875 var2.caub.cElems = 1;
876 var2.caub.pElems = bytevector2;
877
878 res = PropVariantCompareEx(&var1, &var2, 0, 0);
879 ok(res == -1, "res=%i\n", res);
880
881 res = PropVariantCompareEx(&var2, &var1, 0, 0);
882 ok(res == 1, "res=%i\n", res);
883
884 /* Vector length mismatch */
885 var1.caub.cElems = 2;
886 res = PropVariantCompareEx(&var1, &var2, 0, 0);
887 ok(res == -1, "res=%i\n", res);
888
889 res = PropVariantCompareEx(&var2, &var1, 0, 0);
890 ok(res == 1, "res=%i\n", res);
891
892 var1.caub.pElems = bytevector2;
893 var2.caub.pElems = bytevector1;
894 res = PropVariantCompareEx(&var1, &var2, 0, 0);
895 ok(res == 1, "res=%i\n", res);
896
897 var1.caub.pElems = bytevector1;
898 var2.caub.pElems = bytevector2;
899
900 var1.caub.cElems = 1;
901 var2.caub.cElems = 2;
902 res = PropVariantCompareEx(&var1, &var2, 0, 0);
903 ok(res == -1, "res=%i\n", res);
904
905 res = PropVariantCompareEx(&var2, &var1, 0, 0);
906 ok(res == 1, "res=%i\n", res);
907
908 /* Length mismatch over same data */
909 var1.caub.pElems = bytevector1;
910 var2.caub.pElems = bytevector1;
911
912 res = PropVariantCompareEx(&var1, &var2, 0, 0);
913 ok(res == -1, "res=%i\n", res);
914
915 res = PropVariantCompareEx(&var2, &var1, 0, 0);
916 ok(res == 1, "res=%i\n", res);
917
918 var1.caub.cElems = 1;
919 var2.caub.cElems = 1;
920 res = PropVariantCompareEx(&var1, &var2, 0, 0);
921 ok(res == 0, "res=%i\n", res);
922
923 var1.caub.cElems = 0;
925 ok(res == 1, "res=%i\n", res);
927 ok(res == -1, "res=%i\n", res);
928
929 res = PropVariantCompareEx(&var1, &var2, 0, 0);
930 ok(res == -1, "res=%i\n", res);
931 res = PropVariantCompareEx(&var2, &var1, 0, 0);
932 ok(res == 1, "res=%i\n", res);
933
934 var2.caub.cElems = 0;
935 res = PropVariantCompareEx(&var1, &var2, 0, 0);
936 ok(res == 0, "res=%i\n", res);
937
938 SysFreeString(str_2.bstrVal);
939 SysFreeString(str_02.bstrVal);
940 SysFreeString(str_b.bstrVal);
941}
int null(void)
Definition: ftp.c:1794
static const WCHAR empty[]
Definition: main.c:47
@ VT_R4
Definition: compat.h:2299
@ VT_R8
Definition: compat.h:2300
INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2, PROPVAR_COMPARE_UNIT unit, PROPVAR_COMPARE_FLAGS flags)
Definition: propvar.c:961
GLuint res
Definition: glext.h:9613
#define GUID_NULL
Definition: ks.h:106
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
@ PVCF_TREATEMPTYASGREATERTHAN
Definition: propvarutil.h:67
USHORT fFeatures
Definition: compat.h:2356
SAFEARRAYBOUND rgsabound[1]
Definition: compat.h:2360
ULONG cLocks
Definition: compat.h:2358
USHORT cDims
Definition: compat.h:2355
PVOID pvData
Definition: compat.h:2359
ULONG cbElements
Definition: compat.h:2357
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ test_PropVariantToBoolean()

static void test_PropVariantToBoolean ( void  )
static

Definition at line 1072 of file propsys.c.

1073{
1074 static WCHAR str_0[] = {'0',0};
1075 static WCHAR str_1[] = {'1',0};
1076 static WCHAR str_7[] = {'7',0};
1077 static WCHAR str_n7[] = {'-','7',0};
1078 static WCHAR str_true[] = {'t','r','u','e',0};
1079 static WCHAR str_true2[] = {'#','T','R','U','E','#',0};
1080 static WCHAR str_true_case[] = {'t','R','U','e',0};
1081 static WCHAR str_false[] = {'f','a','l','s','e',0};
1082 static WCHAR str_false2[] = {'#','F','A','L','S','E','#',0};
1083 static WCHAR str_true_space[] = {'t','r','u','e',' ',0};
1084 static WCHAR str_yes[] = {'y','e','s',0};
1085 PROPVARIANT propvar;
1086 HRESULT hr;
1087 BOOL val;
1088
1089 /* VT_BOOL */
1090 propvar.vt = VT_BOOL;
1091 propvar.boolVal = VARIANT_FALSE;
1092 val = TRUE;
1093 hr = PropVariantToBoolean(&propvar, &val);
1094 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1095 ok(val == FALSE, "Unexpected value %d\n", val);
1096
1097 propvar.vt = VT_BOOL;
1098 propvar.boolVal = 1;
1099 val = TRUE;
1100 hr = PropVariantToBoolean(&propvar, &val);
1101 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1102 ok(val == FALSE, "Unexpected value %d\n", val);
1103
1104 propvar.vt = VT_BOOL;
1105 propvar.boolVal = VARIANT_TRUE;
1106 val = FALSE;
1107 hr = PropVariantToBoolean(&propvar, &val);
1108 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1109 ok(val == TRUE, "Unexpected value %d\n", val);
1110
1111 /* VT_EMPTY */
1112 propvar.vt = VT_EMPTY;
1113 propvar.boolVal = VARIANT_TRUE;
1114 val = TRUE;
1115 hr = PropVariantToBoolean(&propvar, &val);
1116 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1117 ok(val == FALSE, "Unexpected value %d\n", val);
1118
1119 /* test integer conversion */
1120 propvar.vt = VT_I4;
1121 propvar.lVal = 0;
1122 val = TRUE;
1123 hr = PropVariantToBoolean(&propvar, &val);
1124 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1125 ok(val == FALSE, "Unexpected value %d\n", val);
1126
1127 propvar.vt = VT_I4;
1128 propvar.lVal = 1;
1129 val = FALSE;
1130 hr = PropVariantToBoolean(&propvar, &val);
1131 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1132 ok(val == TRUE, "Unexpected value %d\n", val);
1133
1134 propvar.vt = VT_I4;
1135 propvar.lVal = 67;
1136 val = FALSE;
1137 hr = PropVariantToBoolean(&propvar, &val);
1138 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1139 ok(val == TRUE, "Unexpected value %d\n", val);
1140
1141 propvar.vt = VT_I4;
1142 propvar.lVal = -67;
1143 val = FALSE;
1144 hr = PropVariantToBoolean(&propvar, &val);
1145 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1146 ok(val == TRUE, "Unexpected value %d\n", val);
1147
1148 /* test string conversion */
1149 propvar.vt = VT_LPWSTR;
1150 propvar.pwszVal = str_0;
1151 val = TRUE;
1152 hr = PropVariantToBoolean(&propvar, &val);
1153 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1154 ok(val == FALSE, "Unexpected value %d\n", val);
1155
1156 propvar.vt = VT_LPWSTR;
1157 propvar.pwszVal = str_1;
1158 val = FALSE;
1159 hr = PropVariantToBoolean(&propvar, &val);
1160 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1161 ok(val == TRUE, "Unexpected value %d\n", val);
1162
1163 propvar.vt = VT_LPWSTR;
1164 propvar.pwszVal = str_7;
1165 val = FALSE;
1166 hr = PropVariantToBoolean(&propvar, &val);
1167 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1168 ok(val == TRUE, "Unexpected value %d\n", val);
1169
1170 propvar.vt = VT_LPWSTR;
1171 propvar.pwszVal = str_n7;
1172 val = FALSE;
1173 hr = PropVariantToBoolean(&propvar, &val);
1174 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1175 ok(val == TRUE, "Unexpected value %d\n", val);
1176
1177 propvar.vt = VT_LPWSTR;
1178 propvar.pwszVal = str_true;
1179 val = FALSE;
1180 hr = PropVariantToBoolean(&propvar, &val);
1181 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1182 ok(val == TRUE, "Unexpected value %d\n", val);
1183
1184 propvar.vt = VT_LPWSTR;
1185 propvar.pwszVal = str_true_case;
1186 val = FALSE;
1187 hr = PropVariantToBoolean(&propvar, &val);
1188 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1189 ok(val == TRUE, "Unexpected value %d\n", val);
1190
1191 propvar.vt = VT_LPWSTR;
1192 propvar.pwszVal = str_true2;
1193 val = FALSE;
1194 hr = PropVariantToBoolean(&propvar, &val);
1195 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1196 ok(val == TRUE, "Unexpected value %d\n", val);
1197
1198 propvar.vt = VT_LPWSTR;
1199 propvar.pwszVal = str_false;
1200 val = TRUE;
1201 hr = PropVariantToBoolean(&propvar, &val);
1202 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1203 ok(val == FALSE, "Unexpected value %d\n", val);
1204
1205 propvar.vt = VT_LPWSTR;
1206 propvar.pwszVal = str_false2;
1207 val = TRUE;
1208 hr = PropVariantToBoolean(&propvar, &val);
1209 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1210 ok(val == FALSE, "Unexpected value %d\n", val);
1211
1212 propvar.vt = VT_LPWSTR;
1213 propvar.pwszVal = str_true_space;
1214 val = TRUE;
1215 hr = PropVariantToBoolean(&propvar, &val);
1216 ok(hr == DISP_E_TYPEMISMATCH, "Unexpected hr %#lx.\n", hr);
1217 ok(val == FALSE, "Unexpected value %d\n", val);
1218
1219 propvar.vt = VT_LPWSTR;
1220 propvar.pwszVal = str_yes;
1221 val = TRUE;
1222 hr = PropVariantToBoolean(&propvar, &val);
1223 ok(hr == DISP_E_TYPEMISMATCH, "Unexpected hr %#lx.\n", hr);
1224 ok(val == FALSE, "Unexpected value %d\n", val);
1225
1226 propvar.vt = VT_LPWSTR;
1227 propvar.pwszVal = NULL;
1228 val = TRUE;
1229 hr = PropVariantToBoolean(&propvar, &val);
1230 ok(hr == DISP_E_TYPEMISMATCH, "Unexpected hr %#lx.\n", hr);
1231 ok(val == FALSE, "Unexpected value %d\n", val);
1232
1233 /* VT_LPSTR */
1234 propvar.vt = VT_LPSTR;
1235 propvar.pszVal = (char *)"#TruE#";
1236 val = TRUE;
1237 hr = PropVariantToBoolean(&propvar, &val);
1238 ok(hr == DISP_E_TYPEMISMATCH, "Unexpected hr %#lx.\n", hr);
1239 ok(val == FALSE, "Unexpected value %d\n", val);
1240
1241 propvar.vt = VT_LPSTR;
1242 propvar.pszVal = (char *)"#TRUE#";
1243 val = FALSE;
1244 hr = PropVariantToBoolean(&propvar, &val);
1245 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1246 ok(val == TRUE, "Unexpected value %d\n", val);
1247
1248 propvar.vt = VT_LPSTR;
1249 propvar.pszVal = (char *)"tRUe";
1250 val = FALSE;
1251 hr = PropVariantToBoolean(&propvar, &val);
1252 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1253 ok(val == TRUE, "Unexpected value %d\n", val);
1254
1255 propvar.vt = VT_LPSTR;
1256 propvar.pszVal = (char *)"#FALSE#";
1257 val = TRUE;
1258 hr = PropVariantToBoolean(&propvar, &val);
1259 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1260 ok(val == FALSE, "Unexpected value %d\n", val);
1261
1262 propvar.vt = VT_LPSTR;
1263 propvar.pszVal = (char *)"fALSe";
1264 val = TRUE;
1265 hr = PropVariantToBoolean(&propvar, &val);
1266 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1267 ok(val == FALSE, "Unexpected value %d\n", val);
1268
1269 propvar.vt = VT_LPSTR;
1270 propvar.pszVal = (char *)"1";
1271 val = FALSE;
1272 hr = PropVariantToBoolean(&propvar, &val);
1273 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1274 ok(val == TRUE, "Unexpected value %d\n", val);
1275
1276 propvar.vt = VT_LPSTR;
1277 propvar.pszVal = (char *)"-1";
1278 hr = PropVariantToBoolean(&propvar, &val);
1279 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1280 ok(val == TRUE, "Unexpected value %d\n", val);
1281}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ VT_BOOL
Definition: compat.h:2306
HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
Definition: propvar.c:282
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLfloat * val
Definition: glext.h:7180
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514

Referenced by START_TEST().

◆ test_PropVariantToBSTR()

static void test_PropVariantToBSTR ( void  )
static

Definition at line 1654 of file propsys.c.

1655{
1656 unsigned char test_bytes[] = {1, 20, 30, 4};
1657 WCHAR test_bstr[] = {'a', 0, 'b', 0, 'c'};
1658 PROPVARIANT propvar;
1659 UINT length;
1660 HRESULT hr;
1661 BSTR bstr;
1662
1663 if (0) /* Crashes. */
1664 {
1665 hr = PropVariantToBSTR(&propvar, NULL);
1666 hr = PropVariantToBSTR(NULL, &bstr);
1667 }
1668
1669 todo_wine
1670 {
1671 check_PropVariantToBSTR(VT_I1, cVal, -123, L"-123");
1672 check_PropVariantToBSTR(VT_I2, iVal, -456, L"-456");
1673 check_PropVariantToBSTR(VT_I4, lVal, -789, L"-789");
1674 check_PropVariantToBSTR(VT_I8, hVal.QuadPart, -101112, L"-101112");
1675 check_PropVariantToBSTR(VT_UI1, bVal, 0xcd, L"205");
1676 check_PropVariantToBSTR(VT_UI2, uiVal, 0xdead, L"57005");
1677 check_PropVariantToBSTR(VT_UI4, ulVal, 0xdeadbeef, L"3735928559");
1678 check_PropVariantToBSTR(VT_UI8, uhVal.QuadPart, 0xdeadbeefdeadbeef, L"16045690984833335023");
1679 check_PropVariantToBSTR(VT_BOOL, boolVal, TRUE, L"1");
1680 check_PropVariantToBSTR(VT_R4, fltVal, 0.125f, L"0.125");
1681 check_PropVariantToBSTR(VT_R8, dblVal, 0.456, L"0.456");
1682 }
1683 check_PropVariantToBSTR(VT_CLSID, puuid, (CLSID *)&dummy_guid, dummy_guid_str);
1684 check_PropVariantToBSTR(VT_LPSTR, pszVal, (char *)topic, topicW);
1686
1687 PropVariantInit(&propvar);
1688 propvar.vt = VT_FILETIME;
1689 propvar.filetime.dwLowDateTime = 0xdead;
1690 propvar.filetime.dwHighDateTime = 0xbeef;
1691 hr = PropVariantToBSTR(&propvar, &bstr);
1692 todo_wine
1693 ok(hr == S_OK, "PropVariantToBSTR returned %#lx.\n", hr);
1694 if (hr == S_OK)
1695 {
1696 ok(!wcscmp(bstr, L"1601/08/31:23:29:30.651"), "Unexpected bstr %s.\n", debugstr_w(bstr));
1697 SysFreeString(bstr);
1698 }
1699
1700 PropVariantInit(&propvar);
1701 propvar.vt = VT_DATE;
1702 propvar.date = 123.123f;
1703 hr = PropVariantToBSTR(&propvar, &bstr);
1704 todo_wine
1705 ok(hr == S_OK, "PropVariantToBSTR returned %#lx.\n", hr);
1706 if (hr == S_OK)
1707 {
1708 ok(!wcscmp(bstr, L"1900/05/02:02:57:07.000"), "Unexpected bstr %s.\n", debugstr_w(bstr));
1709 SysFreeString(bstr);
1710 }
1711
1712 PropVariantInit(&propvar);
1713 propvar.vt = VT_VECTOR | VT_I1;
1714 propvar.caub.cElems = ARRAY_SIZE(test_bytes);
1715 propvar.caub.pElems = test_bytes;
1716 hr = PropVariantToBSTR(&propvar, &bstr);
1717 todo_wine
1718 ok(hr == S_OK, "PropVariantToBSTR returned %#lx.\n", hr);
1719 if (hr == S_OK)
1720 {
1721 ok(!wcscmp(bstr, L"1; 20; 30; 4"), "Unexpected bstr %s.\n", debugstr_w(bstr));
1722 SysFreeString(bstr);
1723 }
1724
1725 PropVariantInit(&propvar);
1726 propvar.vt = VT_BSTR;
1727 propvar.bstrVal = SysAllocStringLen(test_bstr, ARRAY_SIZE(test_bstr));
1728 hr = PropVariantToBSTR(&propvar, &bstr);
1729 ok(hr == S_OK, "PropVariantToBSTR returned %#lx.\n", hr);
1730 length = SysStringLen(bstr);
1731 ok(length == wcslen(test_bstr), "Unexpected length %u.\n", length);
1732 ok(!wcscmp(bstr, test_bstr), "Unexpected bstr %s.", debugstr_wn(bstr, ARRAY_SIZE(test_bstr)));
1733 SysFreeString(bstr);
1734 PropVariantClear(&propvar);
1735}
@ VT_I1
Definition: compat.h:2310
@ VT_FILETIME
Definition: compat.h:2329
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define debugstr_wn
Definition: kernel32.h:33
unsigned int UINT
Definition: ndis.h:50
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define check_PropVariantToBSTR(type, member, value, expect_str)
Definition: propsys.c:1635

Referenced by START_TEST().

◆ test_PropVariantToBuffer()

static void test_PropVariantToBuffer ( void  )
static

Definition at line 1737 of file propsys.c.

1738{
1739 PROPVARIANT propvar;
1740 HRESULT hr;
1741 UINT8 data[] = {1,2,3,4,5,6,7,8,9,10};
1742 INT8 data_int8[] = {1,2,3,4,5,6,7,8,9,10};
1743 SAFEARRAY *sa;
1744 SAFEARRAYBOUND sabound;
1745 void *pdata;
1746 UINT8 buffer[256] = {0};
1747
1748 hr = InitPropVariantFromBuffer(data, 10, &propvar);
1749 ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08lx.\n", hr);
1750 hr = PropVariantToBuffer(&propvar, NULL, 0); /* crash when cb isn't zero */
1751 ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1752 PropVariantClear(&propvar);
1753
1754 hr = InitPropVariantFromBuffer(data, 10, &propvar);
1755 ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08lx.\n", hr);
1756 hr = PropVariantToBuffer(&propvar, buffer, 10);
1757 ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1758 ok(!memcmp(buffer, data, 10) && !buffer[10], "got wrong buffer.\n");
1759 memset(buffer, 0, sizeof(buffer));
1760 PropVariantClear(&propvar);
1761
1762 hr = InitPropVariantFromBuffer(data, 10, &propvar);
1763 ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08lx.\n", hr);
1764 buffer[0] = 99;
1765 hr = PropVariantToBuffer(&propvar, buffer, 11);
1766 ok(hr == E_FAIL, "PropVariantToBuffer returned: 0x%08lx.\n", hr);
1767 ok(buffer[0] == 99, "got wrong buffer.\n");
1768 memset(buffer, 0, sizeof(buffer));
1769 PropVariantClear(&propvar);
1770
1771 hr = InitPropVariantFromBuffer(data, 10, &propvar);
1772 ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08lx.\n", hr);
1773 hr = PropVariantToBuffer(&propvar, buffer, 9);
1774 ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1775 ok(!memcmp(buffer, data, 9) && !buffer[9], "got wrong buffer.\n");
1776 memset(buffer, 0, sizeof(buffer));
1777 PropVariantClear(&propvar);
1778
1779 PropVariantInit(&propvar);
1780 propvar.vt = VT_ARRAY|VT_UI1;
1781 sabound.lLbound = 0;
1782 sabound.cElements = sizeof(data);
1783 sa = NULL;
1784 sa = SafeArrayCreate(VT_UI1, 1, &sabound);
1785 ok(sa != NULL, "SafeArrayCreate failed.\n");
1787 ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08lx.\n", hr);
1788 memcpy(pdata, data, sizeof(data));
1790 ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08lx.\n", hr);
1791 propvar.parray = sa;
1792 buffer[0] = 99;
1793 hr = PropVariantToBuffer(&propvar, buffer, 11);
1794 todo_wine ok(hr == E_FAIL, "PropVariantToBuffer returned: 0x%08lx.\n", hr);
1795 ok(buffer[0] == 99, "got wrong buffer.\n");
1796 memset(buffer, 0, sizeof(buffer));
1797 PropVariantClear(&propvar);
1798
1799 PropVariantInit(&propvar);
1800 propvar.vt = VT_ARRAY|VT_UI1;
1801 sabound.lLbound = 0;
1802 sabound.cElements = sizeof(data);
1803 sa = NULL;
1804 sa = SafeArrayCreate(VT_UI1, 1, &sabound);
1805 ok(sa != NULL, "SafeArrayCreate failed.\n");
1807 ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08lx.\n", hr);
1808 memcpy(pdata, data, sizeof(data));
1810 ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08lx.\n", hr);
1811 propvar.parray = sa;
1812 hr = PropVariantToBuffer(&propvar, buffer, sizeof(data));
1813 todo_wine ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1814 todo_wine ok(!memcmp(buffer, data, 10) && !buffer[10], "got wrong buffer.\n");
1815 memset(buffer, 0, sizeof(buffer));
1816 PropVariantClear(&propvar);
1817
1818 PropVariantInit(&propvar);
1819 propvar.vt = VT_VECTOR|VT_I1;
1820 propvar.caub.pElems = CoTaskMemAlloc(sizeof(data_int8));
1821 propvar.caub.cElems = sizeof(data_int8);
1822 memcpy(propvar.caub.pElems, data_int8, sizeof(data_int8));
1823 hr = PropVariantToBuffer(&propvar, buffer, sizeof(data_int8));
1824 ok(hr == E_INVALIDARG, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1825 PropVariantClear(&propvar);
1826
1827 PropVariantInit(&propvar);
1828 propvar.vt = VT_ARRAY|VT_I1;
1829 sabound.lLbound = 0;
1830 sabound.cElements = sizeof(data_int8);
1831 sa = NULL;
1832 sa = SafeArrayCreate(VT_I1, 1, &sabound);
1833 ok(sa != NULL, "SafeArrayCreate failed.\n");
1835 ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08lx.\n", hr);
1836 memcpy(pdata, data_int8, sizeof(data_int8));
1838 ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08lx.\n", hr);
1839 propvar.parray = sa;
1840 hr = PropVariantToBuffer(&propvar, buffer, sizeof(data_int8));
1841 ok(hr == E_INVALIDARG, "PropVariantToBuffer failed: 0x%08lx.\n", hr);
1842 PropVariantClear(&propvar);
1843}
signed char INT8
unsigned char UINT8
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb)
Definition: propvar.c:358
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PROTOCOLDATA * pdata
Definition: protocol.c:158

Referenced by START_TEST().

◆ test_PropVariantToDouble()

static void test_PropVariantToDouble ( void  )
static

Definition at line 1471 of file propsys.c.

1472{
1473 PROPVARIANT propvar;
1474 double value;
1475 HRESULT hr;
1476
1477 PropVariantInit(&propvar);
1478 propvar.vt = VT_R8;
1479 propvar.dblVal = 15.0;
1480 hr = PropVariantToDouble(&propvar, &value);
1481 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1482 ok(value == 15.0, "Unexpected value: %f.\n", value);
1483
1484 PropVariantClear(&propvar);
1485 propvar.vt = VT_I4;
1486 propvar.lVal = 123;
1487 hr = PropVariantToDouble(&propvar, &value);
1488 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1489 ok(value == 123.0, "Unexpected value: %f.\n", value);
1490
1491 PropVariantClear(&propvar);
1492 propvar.vt = VT_I4;
1493 propvar.lVal = -256;
1494 hr = PropVariantToDouble(&propvar, &value);
1495 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1496 ok(value == -256, "Unexpected value: %f\n", value);
1497
1498 PropVariantClear(&propvar);
1499 propvar.vt = VT_I8;
1500 propvar.lVal = 65536;
1501 hr = PropVariantToDouble(&propvar, &value);
1502 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1503 ok(value == 65536.0, "Unexpected value: %f.\n", value);
1504
1505 PropVariantClear(&propvar);
1506 propvar.vt = VT_I8;
1507 propvar.lVal = -321;
1508 hr = PropVariantToDouble(&propvar, &value);
1509 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1510 ok(value == 4294966975.0, "Unexpected value: %f.\n", value);
1511
1512 PropVariantClear(&propvar);
1513 propvar.vt = VT_UI4;
1514 propvar.ulVal = 6;
1515 hr = PropVariantToDouble(&propvar, &value);
1516 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1517 ok(value == 6.0, "Unexpected value: %f.\n", value);
1518
1519 PropVariantClear(&propvar);
1520 propvar.vt = VT_UI8;
1521 propvar.uhVal.QuadPart = 8;
1522 hr = PropVariantToDouble(&propvar, &value);
1523 ok(hr == S_OK, "PropVariantToDouble failed: 0x%08lx.\n", hr);
1524 ok(value == 8.0, "Unexpected value: %f.\n", value);
1525}
HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret)
Definition: propvar.c:184

Referenced by START_TEST().

◆ test_PropVariantToGUID()

static void test_PropVariantToGUID ( void  )
static

Definition at line 567 of file propsys.c.

568{
569 PROPVARIANT propvar;
570 VARIANT var;
571 GUID guid;
573
575 ok(hres == S_OK, "InitPropVariantFromGUIDAsString failed %lx\n", hres);
576
577 hres = PropVariantToGUID(&propvar, &guid);
578 ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres);
579 ok(IsEqualGUID(&IID_NULL, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
580 PropVariantClear(&propvar);
581
582 hres = InitPropVariantFromGUIDAsString(&dummy_guid, &propvar);
583 ok(hres == S_OK, "InitPropVariantFromGUIDAsString failed %lx\n", hres);
584
585 hres = PropVariantToGUID(&propvar, &guid);
586 ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres);
587 ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
588
589 ok(propvar.vt == VT_LPWSTR, "incorrect PROPVARIANT type: %d\n", propvar.vt);
590 propvar.pwszVal[1] = 'd';
591 propvar.pwszVal[2] = 'E';
592 propvar.pwszVal[3] = 'a';
593 hres = PropVariantToGUID(&propvar, &guid);
594 ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres);
595 ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
596
597 propvar.pwszVal[1] = 'z';
598 hres = PropVariantToGUID(&propvar, &guid);
599 ok(hres == E_INVALIDARG, "PropVariantToGUID returned %lx\n", hres);
600 PropVariantClear(&propvar);
601
602
604 ok(hres == S_OK, "InitVariantFromGUIDAsString failed %lx\n", hres);
605
607 ok(hres == S_OK, "VariantToGUID failed %lx\n", hres);
608 ok(IsEqualGUID(&IID_NULL, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
610
611 hres = InitVariantFromGUIDAsString(&dummy_guid, &var);
612 ok(hres == S_OK, "InitVariantFromGUIDAsString failed %lx\n", hres);
613
615 ok(hres == S_OK, "VariantToGUID failed %lx\n", hres);
616 ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
617
618 ok(V_VT(&var) == VT_BSTR, "incorrect VARIANT type: %d\n", V_VT(&var));
619 V_BSTR(&var)[1] = 'z';
621 ok(hres == E_FAIL, "VariantToGUID returned %lx\n", hres);
622
623 V_BSTR(&var)[1] = 'd';
624 propvar.vt = V_VT(&var);
625 propvar.bstrVal = V_BSTR(&var);
626 V_VT(&var) = VT_EMPTY;
627 hres = PropVariantToGUID(&propvar, &guid);
628 ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres);
629 ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
630 PropVariantClear(&propvar);
631
632 memset(&guid, 0, sizeof(guid));
633 InitPropVariantFromCLSID(&dummy_guid, &propvar);
634 hres = PropVariantToGUID(&propvar, &guid);
635 ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres);
636 ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid));
637 PropVariantClear(&propvar);
638}
HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid)
Definition: propvar.c:919
HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid)
Definition: propvar.c:900
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

Referenced by START_TEST().

◆ test_PropVariantToString()

static void test_PropVariantToString ( void  )
static

Definition at line 1527 of file propsys.c.

1528{
1529 static WCHAR stringW[] = L"Wine";
1530 static CHAR string[] = "Wine";
1531 WCHAR bufferW[256] = {0};
1532 PROPVARIANT propvar;
1533 HRESULT hr;
1534
1535 PropVariantInit(&propvar);
1536 propvar.vt = VT_EMPTY;
1537 propvar.pwszVal = stringW;
1538 bufferW[0] = 65;
1539 hr = PropVariantToString(&propvar, bufferW, 0);
1540 ok(hr == E_INVALIDARG, "PropVariantToString should fail: 0x%08lx.\n", hr);
1541 ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1542 memset(bufferW, 0, sizeof(bufferW));
1543 PropVariantClear(&propvar);
1544
1545 PropVariantInit(&propvar);
1546 propvar.vt = VT_EMPTY;
1547 propvar.pwszVal = stringW;
1548 bufferW[0] = 65;
1549 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1550 ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1551 ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1552 memset(bufferW, 0, sizeof(bufferW));
1553 PropVariantClear(&propvar);
1554
1555 PropVariantInit(&propvar);
1556 propvar.vt = VT_NULL;
1557 propvar.pwszVal = stringW;
1558 bufferW[0] = 65;
1559 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1560 ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1561 ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1562 memset(bufferW, 0, sizeof(bufferW));
1563 PropVariantClear(&propvar);
1564
1565 PropVariantInit(&propvar);
1566 propvar.vt = VT_I4;
1567 propvar.lVal = 22;
1568 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1569 todo_wine ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1570 todo_wine ok(!lstrcmpW(bufferW, L"22"), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1571 memset(bufferW, 0, sizeof(bufferW));
1572 PropVariantClear(&propvar);
1573
1574 PropVariantInit(&propvar);
1575 propvar.vt = VT_LPWSTR;
1576 propvar.pwszVal = stringW;
1577 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1578 ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1579 ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1580 memset(bufferW, 0, sizeof(bufferW));
1581
1582 PropVariantInit(&propvar);
1583 propvar.vt = VT_LPSTR;
1584 propvar.pszVal = string;
1585 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1586 ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1587 ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1588 memset(bufferW, 0, sizeof(bufferW));
1589
1590 /* Result string will be truncated if output buffer is too small. */
1591 PropVariantInit(&propvar);
1592 propvar.vt = VT_UI4;
1593 propvar.lVal = 123456;
1594 hr = PropVariantToString(&propvar, bufferW, 4);
1595 todo_wine
1596 ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "PropVariantToString returned: %#lx.\n", hr);
1597 todo_wine
1598 ok(!wcscmp(bufferW, L"123"), "Unexpected string %s.\n", debugstr_w(bufferW));
1599 memset(bufferW, 0, sizeof(bufferW));
1600
1601 PropVariantInit(&propvar);
1602 propvar.vt = VT_LPWSTR;
1603 propvar.pwszVal = stringW;
1604 hr = PropVariantToString(&propvar, bufferW, 4);
1605 ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "PropVariantToString returned: 0x%08lx.\n", hr);
1606 ok(!wcscmp(bufferW, L"Win"), "Unexpected string %s.\n", debugstr_w(bufferW));
1607 memset(bufferW, 0, sizeof(bufferW));
1608
1609 PropVariantInit(&propvar);
1610 propvar.vt = VT_LPSTR;
1611 propvar.pszVal = string;
1612 hr = PropVariantToString(&propvar, bufferW, 4);
1613 ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "PropVariantToString returned: 0x%08lx.\n", hr);
1614 ok(!wcscmp(bufferW, L"Win"), "Unexpected string %s.\n", debugstr_w(bufferW));
1615 memset(bufferW, 0, sizeof(bufferW));
1616
1617 PropVariantInit(&propvar);
1618 propvar.vt = VT_BSTR;
1619 propvar.bstrVal = SysAllocString(stringW);
1620 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1621 ok(hr == S_OK, "PropVariantToString failed: 0x%08lx.\n", hr);
1622 ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW));
1623 memset(bufferW, 0, sizeof(bufferW));
1624 SysFreeString(propvar.bstrVal);
1625
1626 PropVariantInit(&propvar);
1627 propvar.vt = VT_CLSID;
1628 propvar.puuid = (CLSID *)&dummy_guid;
1629 hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW));
1630 ok(hr == S_OK, "PropVariantToString returned %#lx.\n", hr);
1631 ok(!wcscmp(bufferW, dummy_guid_str), "Unexpected string %s.\n", debugstr_w(bufferW));
1632 memset(bufferW, 0, sizeof(bufferW));
1633}
HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch)
Definition: propvar.c:383
static const WCHAR stringW[]
Definition: engine.c:38
char string[160]
Definition: util.h:11
#define STRSAFE_E_INSUFFICIENT_BUFFER
Definition: strsafe.h:103
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_PropVariantToStringAlloc()

static void test_PropVariantToStringAlloc ( void  )
static

Definition at line 640 of file propsys.c.

641{
642 PROPVARIANT prop;
643 WCHAR *str;
645
646 prop.vt = VT_NULL;
648 ok(hres == S_OK, "returned %lx\n", hres);
649 ok(!lstrcmpW(str, emptyW), "got %s\n", wine_dbgstr_w(str));
651
652 prop.vt = VT_LPSTR;
653 prop.pszVal = CoTaskMemAlloc(strlen(topic)+1);
654 strcpy(prop.pszVal, topic);
656 ok(hres == S_OK, "returned %lx\n", hres);
657 ok(!lstrcmpW(str, topicW), "got %s\n", wine_dbgstr_w(str));
659 PropVariantClear(&prop);
660
661 prop.vt = VT_EMPTY;
663 ok(hres == S_OK, "returned %lx\n", hres);
664 ok(!lstrcmpW(str, emptyW), "got %s\n", wine_dbgstr_w(str));
666
667 prop.vt = VT_CLSID;
668 prop.puuid = (CLSID *)&dummy_guid;
670 ok(hres == S_OK, "PropVariantToStringAlloc returned %#lx.\n", hres);
671 ok(!wcscmp(str, dummy_guid_str), "Unexpected str %s.\n", debugstr_w(str));
673}
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
Definition: propvar.c:407

Referenced by START_TEST().

◆ test_PropVariantToStringWithDefault()

static void test_PropVariantToStringWithDefault ( void  )
static

Definition at line 1283 of file propsys.c.

1284{
1285 PROPVARIANT propvar;
1286 static WCHAR default_value[] = {'t', 'e', 's', 't', 0};
1287 static WCHAR wstr_test2[] = {'t', 'e', 's', 't', '2', 0};
1288 static WCHAR wstr_empty[] = {0};
1289 static WCHAR wstr_space[] = {' ', 0};
1290 static CHAR str_test2[] = "test2";
1291 static CHAR str_empty[] = "";
1292 static CHAR str_space[] = " ";
1294
1295 propvar.vt = VT_EMPTY;
1296 result = PropVariantToStringWithDefault(&propvar, default_value);
1297 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1298
1299 propvar.vt = VT_NULL;
1300 result = PropVariantToStringWithDefault(&propvar, default_value);
1301 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1302
1303 propvar.vt = VT_BOOL;
1304 propvar.boolVal = VARIANT_TRUE;
1305 result = PropVariantToStringWithDefault(&propvar, default_value);
1306 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1307
1308 propvar.vt = VT_I4;
1309 propvar.lVal = 15;
1310 result = PropVariantToStringWithDefault(&propvar, default_value);
1311 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1312
1313 propvar.vt = VT_CLSID;
1314 propvar.puuid = (CLSID *)&dummy_guid;
1315 result = PropVariantToStringWithDefault(&propvar, default_value);
1316 ok(result == default_value, "Unexpected value %s.\n", debugstr_w(result));
1317
1318 /* VT_LPWSTR */
1319
1320 propvar.vt = VT_LPWSTR;
1321 propvar.pwszVal = NULL;
1322 result = PropVariantToStringWithDefault(&propvar, default_value);
1323 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1324
1325 propvar.vt = VT_LPWSTR;
1326 propvar.pwszVal = wstr_empty;
1327 result = PropVariantToStringWithDefault(&propvar, default_value);
1328 ok(result == wstr_empty, "Unexpected value %s\n", wine_dbgstr_w(result));
1329
1330 propvar.vt = VT_LPWSTR;
1331 propvar.pwszVal = wstr_space;
1332 result = PropVariantToStringWithDefault(&propvar, default_value);
1333 ok(result == wstr_space, "Unexpected value %s\n", wine_dbgstr_w(result));
1334
1335 propvar.vt = VT_LPWSTR;
1336 propvar.pwszVal = wstr_test2;
1337 result = PropVariantToStringWithDefault(&propvar, default_value);
1338 ok(result == wstr_test2, "Unexpected value %s\n", wine_dbgstr_w(result));
1339
1340 /* VT_LPSTR */
1341
1342 propvar.vt = VT_LPSTR;
1343 propvar.pszVal = NULL;
1344 result = PropVariantToStringWithDefault(&propvar, default_value);
1345 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1346
1347 propvar.vt = VT_LPSTR;
1348 propvar.pszVal = str_empty;
1349 result = PropVariantToStringWithDefault(&propvar, default_value);
1350 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1351
1352 propvar.vt = VT_LPSTR;
1353 propvar.pszVal = str_space;
1354 result = PropVariantToStringWithDefault(&propvar, default_value);
1355 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1356
1357 propvar.vt = VT_LPSTR;
1358 propvar.pszVal = str_test2;
1359 result = PropVariantToStringWithDefault(&propvar, default_value);
1360 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
1361
1362 /* VT_BSTR */
1363
1364 propvar.vt = VT_BSTR;
1365 propvar.bstrVal = NULL;
1366 result = PropVariantToStringWithDefault(&propvar, default_value);
1367 ok(!lstrcmpW(result, wstr_empty), "Unexpected value %s\n", wine_dbgstr_w(result));
1368
1369 propvar.vt = VT_BSTR;
1370 propvar.bstrVal = SysAllocString(wstr_empty);
1371 result = PropVariantToStringWithDefault(&propvar, default_value);
1372 ok(!lstrcmpW(result, wstr_empty), "Unexpected value %s\n", wine_dbgstr_w(result));
1373 SysFreeString(propvar.bstrVal);
1374
1375 propvar.vt = VT_BSTR;
1376 propvar.bstrVal = SysAllocString(wstr_space);
1377 result = PropVariantToStringWithDefault(&propvar, default_value);
1378 ok(!lstrcmpW(result, wstr_space), "Unexpected value %s\n", wine_dbgstr_w(result));
1379 SysFreeString(propvar.bstrVal);
1380
1381 propvar.vt = VT_BSTR;
1382 propvar.bstrVal = SysAllocString(wstr_test2);
1383 result = PropVariantToStringWithDefault(&propvar, default_value);
1384 ok(!lstrcmpW(result, wstr_test2), "Unexpected value %s\n", wine_dbgstr_w(result));
1385 SysFreeString(propvar.bstrVal);
1386}
PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault)
Definition: propvar.c:467
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ test_PropVariantToVariant()

static void test_PropVariantToVariant ( void  )
static

Definition at line 2544 of file propsys.c.

2545{
2546 PROPVARIANT propvar;
2547 VARIANT var;
2548 HRESULT hr;
2549
2550 VariantInit(&var);
2551 PropVariantInit(&propvar);
2552
2554 ok(hr == E_INVALIDARG, "PropVariantToVariant returned %#lx.\n", hr);
2555 hr = PropVariantToVariant(&propvar, NULL);
2556 ok(hr == E_INVALIDARG, "PropVariantToVariant returned %#lx.\n", hr);
2557
2558 propvar.vt = 0xdead;
2559 hr = PropVariantToVariant(&propvar, &var);
2560 todo_wine
2561 ok(hr == E_OUTOFMEMORY, "PropVariantToVariant returned %#lx.\n", hr);
2562 propvar.vt = VT_ILLEGAL;
2563 hr = PropVariantToVariant(&propvar, &var);
2564 todo_wine
2565 ok(hr == E_OUTOFMEMORY, "PropVariantToVariant returned %#lx.\n", hr);
2566
2567 propvar.vt = VT_EMPTY;
2568 hr = PropVariantToVariant(&propvar, &var);
2569 ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr);
2570 ok(V_VT(&var) == VT_EMPTY, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2571
2572 propvar.vt = VT_NULL;
2573 hr = PropVariantToVariant(&propvar, &var);
2574 ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr);
2575 ok(V_VT(&var) == VT_NULL, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2576
2577 check_PropVariantToVariant(propvar, var, I1, cVal, 'X', "%c");
2578 check_PropVariantToVariant(propvar, var, I2, iVal, -456, "%d");
2579 check_PropVariantToVariant(propvar, var, I4, lVal, -789, "%ld");
2580 check_PropVariantToVariant(propvar, var, I8, hVal.QuadPart, -101112, "%I64d");
2581
2582 check_PropVariantToVariant(propvar, var, UI1, bVal, 0xcd, "%#x");
2583 check_PropVariantToVariant(propvar, var, UI2, uiVal, 0xdead, "%#x");
2584 check_PropVariantToVariant(propvar, var, UI4, ulVal, 0xdeadbeef, "%#lx");
2585 check_PropVariantToVariant(propvar, var, UI8, uhVal.QuadPart, 0xdeadbeefdeadbeef, "%I64x");
2586
2587 check_PropVariantToVariant(propvar, var, BOOL, boolVal, TRUE, "%d");
2588
2589 check_PropVariantToVariant(propvar, var, R4, fltVal, 0.123f, "%f");
2590 check_PropVariantToVariant(propvar, var, R8, dblVal, 0.456f, "%f");
2591
2592 propvar.vt = VT_BSTR;
2593 propvar.bstrVal = SysAllocString(L"test");
2594 hr = PropVariantToVariant(&propvar, &var);
2595 ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr);
2596 ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2597 ok(V_BSTR(&var) != propvar.bstrVal, "Got same string pointer.\n");
2598 ok(!wcscmp(V_BSTR(&var), propvar.bstrVal), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var)));
2599 PropVariantClear(&propvar);
2600 VariantClear(&var);
2601
2602 propvar.vt = VT_CLSID;
2603 propvar.puuid = (GUID *)&dummy_guid;
2604 hr = PropVariantToVariant(&propvar, &var);
2605 todo_wine
2606 ok(hr == 39, "PropVariantToVariant returned %#lx.\n", hr);
2607 ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2608 ok(!wcscmp(V_BSTR(&var), dummy_guid_str), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var)));
2609 VariantClear(&var);
2610
2611 propvar.vt = VT_LPSTR;
2612 propvar.pszVal = (char *)topic;
2613 hr = PropVariantToVariant(&propvar, &var);
2614 ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr);
2615 ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2616 ok(!wcscmp(V_BSTR(&var), topicW), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var)));
2617 VariantClear(&var);
2618
2619 propvar.vt = VT_LPWSTR;
2620 propvar.pwszVal = (WCHAR *)topicW;
2621 hr = PropVariantToVariant(&propvar, &var);
2622 ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr);
2623 ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var));
2624 ok(V_BSTR(&var) != topicW, "Got same string pointer.\n");
2625 ok(!wcscmp(V_BSTR(&var), topicW), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var)));
2626 VariantClear(&var);
2627}
@ R8
Definition: amd64_sup.c:13
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
@ VT_ILLEGAL
Definition: compat.h:2344
#define check_PropVariantToVariant(propvar, var, type, member, value, format)
Definition: propsys.c:2470
#define R4(v, w, x, y, z, i)
Definition: sha1.c:39

Referenced by START_TEST().

◆ test_PSCreateMemoryPropertyStore()

static void test_PSCreateMemoryPropertyStore ( void  )
static

Definition at line 2069 of file propsys.c.

2070{
2071 IPropertyStore *propstore, *propstore1;
2073 IPropertyStoreCache *propstorecache;
2074 HRESULT hr;
2075
2076 /* PSCreateMemoryPropertyStore(&IID_IPropertyStore, NULL); crashes */
2077
2078 hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore);
2079 ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08lx.\n", hr);
2080 ok(propstore != NULL, "got %p.\n", propstore);
2081 EXPECT_REF(propstore, 1);
2082
2083 hr = PSCreateMemoryPropertyStore(&IID_IPersistSerializedPropStorage, (void **)&serialized);
2084 todo_wine ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08lx.\n", hr);
2085 todo_wine ok(serialized != NULL, "got %p.\n", serialized);
2086 EXPECT_REF(propstore, 1);
2087 if(serialized)
2088 {
2089 EXPECT_REF(serialized, 1);
2090 IPersistSerializedPropStorage_Release(serialized);
2091 }
2092
2093 hr = PSCreateMemoryPropertyStore(&IID_IPropertyStoreCache, (void **)&propstorecache);
2094 ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08lx.\n", hr);
2095 ok(propstorecache != NULL, "got %p.\n", propstore);
2096 ok(propstorecache != (IPropertyStoreCache *)propstore, "pointer are equal: %p, %p.\n", propstorecache, propstore);
2097 EXPECT_REF(propstore, 1);
2098 EXPECT_REF(propstorecache, 1);
2099
2100 hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore1);
2101 ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08lx.\n", hr);
2102 ok(propstore1 != NULL, "got %p.\n", propstore);
2103 ok(propstore1 != propstore, "pointer are equal: %p, %p.\n", propstore1, propstore);
2104 EXPECT_REF(propstore, 1);
2105 EXPECT_REF(propstore1, 1);
2106 EXPECT_REF(propstorecache, 1);
2107
2108 IPropertyStore_Release(propstore1);
2109 IPropertyStore_Release(propstore);
2110 IPropertyStoreCache_Release(propstorecache);
2111}
#define EXPECT_REF(obj, ref)
Definition: propsys.c:50

Referenced by START_TEST().

◆ test_PSCreatePropertyStoreFromObject()

static void test_PSCreatePropertyStoreFromObject ( void  )
static

Definition at line 2171 of file propsys.c.

2172{
2173 IPropertyStore *propstore;
2174 IUnknown *unk;
2175 HRESULT hr;
2176
2177 hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore);
2178 ok(hr == S_OK, "Failed to create property store, hr %#lx.\n", hr);
2179
2181 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
2182
2184 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
2185
2186 hr = PSCreatePropertyStoreFromObject((IUnknown *)propstore, STGM_READWRITE, &IID_IUnknown, (void **)&unk);
2187 todo_wine
2188 ok(hr == S_OK, "Failed to create wrapper, hr %#lx.\n", hr);
2189 if (SUCCEEDED(hr))
2190 {
2191 ok(unk != (IUnknown *)propstore, "Unexpected object returned.\n");
2192 IUnknown_Release(unk);
2193 }
2194
2195 hr = PSCreatePropertyStoreFromObject((IUnknown *)propstore, STGM_READWRITE, &IID_IPropertyStore, (void **)&unk);
2196 ok(hr == S_OK, "Failed to create wrapper, hr %#lx.\n", hr);
2197 ok(unk == (IUnknown *)propstore, "Unexpected object returned.\n");
2198 IUnknown_Release(unk);
2199
2200 IPropertyStore_Release(propstore);
2201}
const GUID IID_IUnknown
HRESULT WINAPI PSCreatePropertyStoreFromObject(IUnknown *obj, DWORD access, REFIID riid, void **ret)
Definition: propstore.c:481
#define STGM_READWRITE
Definition: objbase.h:919

Referenced by START_TEST().

◆ test_PSPropertyKeyFromString()

static void test_PSPropertyKeyFromString ( void  )
static

Definition at line 162 of file propsys.c.

163{
164 static const WCHAR fmtid_clsidW[] = {'S','t','d','F','o','n','t',' ','1',0};
165 static const WCHAR fmtid_truncatedW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
166 '1','2','3','4','-',0};
167 static const WCHAR fmtid_nobracketsW[] = {'1','2','3','4','5','6','7','8','-','1','2','3','4','-',
168 '1','2','3','4','-','1','2','3','4','-',
169 '1','2','3','4','5','6','7','8','9','0','1','2',0};
170 static const WCHAR fmtid_badbracketW[] = {'X','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
171 '1','2','3','4','-','1','2','3','4','-',
172 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
173 static const WCHAR fmtid_badcharW[] = {'{','X','2','3','4','5','6','7','8','-','1','2','3','4','-',
174 '1','2','3','4','-','1','2','3','4','-',
175 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
176 static const WCHAR fmtid_badchar2W[] = {'{','1','2','3','4','5','6','7','X','-','1','2','3','4','-',
177 '1','2','3','4','-','1','2','3','4','-',
178 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
179 static const WCHAR fmtid_baddashW[] = {'{','1','2','3','4','5','6','7','8','X','1','2','3','4','-',
180 '1','2','3','4','-','1','2','3','4','-',
181 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
182 static const WCHAR fmtid_badchar3W[] = {'{','1','2','3','4','5','6','7','8','-','X','2','3','4','-',
183 '1','2','3','4','-','1','2','3','4','-',
184 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
185 static const WCHAR fmtid_badchar4W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','X','-',
186 '1','2','3','4','-','1','2','3','4','-',
187 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
188 static const WCHAR fmtid_baddash2W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','X',
189 '1','2','3','4','-','1','2','3','4','-',
190 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
191 static const WCHAR fmtid_badchar5W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
192 'X','2','3','4','-','1','2','3','4','-',
193 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
194 static const WCHAR fmtid_badchar6W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
195 '1','2','3','X','-','1','2','3','4','-',
196 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
197 static const WCHAR fmtid_baddash3W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
198 '1','2','3','4','X','1','2','3','4','-',
199 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
200 static const WCHAR fmtid_badchar7W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
201 '1','2','3','4','-','X','2','3','4','-',
202 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
203 static const WCHAR fmtid_badchar8W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
204 '1','2','3','4','-','1','2','3','X','-',
205 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
206 static const WCHAR fmtid_baddash4W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
207 '1','2','3','4','-','1','2','3','4','X',
208 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
209 static const WCHAR fmtid_badchar9W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
210 '1','2','3','4','-','1','2','3','4','-',
211 'X','2','3','4','5','6','7','8','9','0','1','2','}',0};
212 static const WCHAR fmtid_badchar9_adjW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
213 '1','2','3','4','-','1','2','3','4','-',
214 '1','X','3','4','5','6','7','8','9','0','1','2','}',0};
215 static const WCHAR fmtid_badchar10W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
216 '1','2','3','4','-','1','2','3','4','-',
217 '1','2','X','4','5','6','7','8','9','0','1','2','}',0};
218 static const WCHAR fmtid_badchar11W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
219 '1','2','3','4','-','1','2','3','4','-',
220 '1','2','3','4','X','6','7','8','9','0','1','2','}',0};
221 static const WCHAR fmtid_badchar12W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
222 '1','2','3','4','-','1','2','3','4','-',
223 '1','2','3','4','5','6','X','8','9','0','1','2','}',0};
224 static const WCHAR fmtid_badchar13W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
225 '1','2','3','4','-','1','2','3','4','-',
226 '1','2','3','4','5','6','7','8','X','0','1','2','}',0};
227 static const WCHAR fmtid_badchar14W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
228 '1','2','3','4','-','1','2','3','4','-',
229 '1','2','3','4','5','6','7','8','9','0','X','2','}',0};
230 static const WCHAR fmtid_badbracket2W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
231 '1','2','3','4','-','1','2','3','4','-',
232 '1','2','3','4','5','6','7','8','9','0','1','2','X',0};
233 static const WCHAR fmtid_spaceW[] = {' ','{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
234 '1','2','3','4','-','1','2','3','4','-',
235 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
236 static const WCHAR fmtid_spaceendW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
237 '1','2','3','4','-','1','2','3','4','-',
238 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',0};
239 static const WCHAR fmtid_spacesendW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
240 '1','2','3','4','-','1','2','3','4','-',
241 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ',0};
242 static const WCHAR fmtid_nopidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
243 '1','2','3','4','-','1','2','3','4','-',
244 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
245 static const WCHAR fmtid_badpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
246 '1','2','3','4','-','1','2','3','4','-',
247 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','D','E','A','D',0};
248 static const WCHAR fmtid_adjpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
249 '1','2','3','4','-','1','2','3','4','-',
250 '1','2','3','4','5','6','7','8','9','0','1','2','}','1','3','5','7','9',0};
251 static const WCHAR fmtid_spacespidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
252 '1','2','3','4','-','1','2','3','4','-',
253 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ','1','3','5','7','9',0};
254 static const WCHAR fmtid_negpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
255 '1','2','3','4','-','1','2','3','4','-',
256 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','1','3','5','7','9',0};
257 static const WCHAR fmtid_negnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
258 '1','2','3','4','-','1','2','3','4','-',
259 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','1','3','5','7','9',0};
260 static const WCHAR fmtid_negnegnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
261 '1','2','3','4','-','1','2','3','4','-',
262 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','-','1','3','5','7','9',0};
263 static const WCHAR fmtid_negspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
264 '1','2','3','4','-','1','2','3','4','-',
265 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','1','3','5','7','9',0};
266 static const WCHAR fmtid_negspacenegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
267 '1','2','3','4','-','1','2','3','4','-',
268 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-','1','3','5','7','9',0};
269 static const WCHAR fmtid_negspacespidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
270 '1','2','3','4','-','1','2','3','4','-',
271 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-',' ','-','1','3','5','7','9',0};
272 static const WCHAR fmtid_pospidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
273 '1','2','3','4','-','1','2','3','4','-',
274 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','1','3','5','7','9',0};
275 static const WCHAR fmtid_posnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
276 '1','2','3','4','-','1','2','3','4','-',
277 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','-','+','-','1','3','5','7','9',0};
278 static const WCHAR fmtid_symbolpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
279 '1','2','3','4','-','1','2','3','4','-',
280 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','/','$','-','1','3','5','7','9',0};
281 static const WCHAR fmtid_letterpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
282 '1','2','3','4','-','1','2','3','4','-',
283 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','B','C','D','1','3','5','7','9',0};
284 static const WCHAR fmtid_spacepadpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
285 '1','2','3','4','-','1','2','3','4','-',
286 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',' ',' ',' ',0};
287 static const WCHAR fmtid_spacemixpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
288 '1','2','3','4','-','1','2','3','4','-',
289 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1',' ','3',' ','5','7','9',' ',' ',' ',0};
290 static const WCHAR fmtid_tabpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
291 '1','2','3','4','-','1','2','3','4','-',
292 '1','2','3','4','5','6','7','8','9','0','1','2','}','\t','1','3','5','7','9',0};
293 static const WCHAR fmtid_hexpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
294 '1','2','3','4','-','1','2','3','4','-',
295 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','0','x','D','E','A','D',0};
296 static const WCHAR fmtid_mixedpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
297 '1','2','3','4','-','1','2','3','4','-',
298 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','9','B','5','C','3','D','1',0};
299 static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
300 '1','2','3','4','-','1','2','3','4','-',
301 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
302 static const WCHAR fmtid_commapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
303 '1','2','3','4','-','1','2','3','4','-',
304 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','1','3','5','7','9',0};
305 static const WCHAR fmtid_commaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
306 '1','2','3','4','-','1','2','3','4','-',
307 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',',',',','1','3','5','7','9',0};
308 static const WCHAR fmtid_commaspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
309 '1','2','3','4','-','1','2','3','4','-',
310 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','1','3','5','7','9',0};
311 static const WCHAR fmtid_spacecommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
312 '1','2','3','4','-','1','2','3','4','-',
313 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','1','3','5','7','9',0};
314 static const WCHAR fmtid_spccommaspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
315 '1','2','3','4','-','1','2','3','4','-',
316 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','1','3','5','7','9',0};
317 static const WCHAR fmtid_spacescommaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
318 '1','2','3','4','-','1','2','3','4','-',
319 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ',',','1','3','5','7','9',0};
320 static const WCHAR fmtid_commanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
321 '1','2','3','4','-','1','2','3','4','-',
322 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-','1','3','5','7','9',0};
323 static const WCHAR fmtid_spccommanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
324 '1','2','3','4','-','1','2','3','4','-',
325 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','-','1','3','5','7','9',0};
326 static const WCHAR fmtid_commaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
327 '1','2','3','4','-','1','2','3','4','-',
328 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','-','1','3','5','7','9',0};
329 static const WCHAR fmtid_spccommaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
330 '1','2','3','4','-','1','2','3','4','-',
331 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','-','1','3','5','7','9',0};
332 static const WCHAR fmtid_commanegspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
333 '1','2','3','4','-','1','2','3','4','-',
334 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-',' ','1','3','5','7','9',0};
335 static const WCHAR fmtid_negcommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
336 '1','2','3','4','-','1','2','3','4','-',
337 '1','2','3','4','5','6','7','8','9','0','1','2','}','-',',','1','3','5','7','9',0};
338 static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
339 '1','2','3','4','-','1','2','3','4','-',
340 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
341 static const WCHAR fmtid_udigitW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
342 '1','2','3','4','-','1','2','3','4','-',
343 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3',0x661,'5','7','9',0};
344 PROPERTYKEY out_init = {GUID_MEMBERS(dummy_guid), 0xdeadbeef};
345 PROPERTYKEY out;
346 HRESULT ret;
347
348 const struct
349 {
350 LPCWSTR pwzString;
351 PROPERTYKEY *pkey;
352 HRESULT hr_expect;
353 PROPERTYKEY pkey_expect;
354 } testcases[] =
355 {
356 {NULL, NULL, E_POINTER},
357 {NULL, &out, E_POINTER, {GUID_MEMBERS(out_init.fmtid), out_init.pid}},
360 {fmtid_clsidW, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0}},
361 {fmtid_truncatedW, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
362 {fmtid_nobracketsW, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0}},
363 {fmtid_badbracketW, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0}},
364 {fmtid_badcharW, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0}},
365 {fmtid_badchar2W, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0}},
366 {fmtid_baddashW, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
367 {fmtid_badchar3W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
368 {fmtid_badchar4W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
369 {fmtid_baddash2W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
370 {fmtid_badchar5W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
371 {fmtid_badchar6W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
372 {fmtid_baddash3W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
373 {fmtid_badchar7W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
374 {fmtid_badchar8W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
375 {fmtid_baddash4W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
376 {fmtid_badchar9W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
377 {fmtid_badchar9_adjW, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
378 {fmtid_badchar10W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0,0,0,0,0}}, 0}},
379 {fmtid_badchar11W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0,0,0,0}}, 0}},
380 {fmtid_badchar12W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0,0,0}}, 0}},
381 {fmtid_badchar13W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0,0}}, 0}},
382 {fmtid_badchar14W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0}}, 0}},
383 {fmtid_badbracket2W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x00}}, 0 }},
384 {fmtid_spaceW, &out, E_INVALIDARG, {GUID_MEMBERS(GUID_NULL), 0 }},
385 {fmtid_spaceendW, &out, E_INVALIDARG, {GUID_MEMBERS(expect_guid), 0}},
386 {fmtid_spacesendW, &out, E_INVALIDARG, {GUID_MEMBERS(expect_guid), 0}},
387 {fmtid_nopidW, &out, E_INVALIDARG, {GUID_MEMBERS(expect_guid), 0}},
388 {fmtid_badpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
389 {fmtid_adjpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
390 {fmtid_spacespidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
391 {fmtid_negpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
392 {fmtid_negnegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
393 {fmtid_negnegnegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
394 {fmtid_negspacepidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
395 {fmtid_negspacenegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
396 {fmtid_negspacespidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
397 {fmtid_pospidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
398 {fmtid_posnegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
399 {fmtid_symbolpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
400 {fmtid_letterpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
401 {fmtid_spacepadpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
402 {fmtid_spacemixpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 1}},
403 {fmtid_tabpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
404 {fmtid_hexpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
405 {fmtid_mixedpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
406 {fmtid_overflowpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 3755744309U}},
407 {fmtid_commapidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
408 {fmtid_commaspidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
409 {fmtid_commaspacepidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
410 {fmtid_spacecommapidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
411 {fmtid_spccommaspcpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
412 {fmtid_spacescommaspidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
413 {fmtid_commanegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
414 {fmtid_spccommanegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
415 {fmtid_commaspcnegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
416 {fmtid_spccommaspcnegpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 4294953717U}},
417 {fmtid_commanegspcpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0U}},
418 {fmtid_negcommapidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 0}},
419 {fmtid_normalpidW, &out, S_OK, {GUID_MEMBERS(expect_guid), 13579}},
420 {fmtid_udigitW, &out, S_OK, {GUID_MEMBERS(expect_guid), 123}},
421 };
422
423 int i;
424
425 for (i = 0; i < ARRAY_SIZE(testcases); i++)
426 {
427 if (testcases[i].pkey)
428 *testcases[i].pkey = out_init;
429
430 ret = PSPropertyKeyFromString(testcases[i].pwzString, testcases[i].pkey);
431 ok(ret == testcases[i].hr_expect,
432 "[%d] Expected PSPropertyKeyFromString to return 0x%08lx, got 0x%08lx\n",
433 i, testcases[i].hr_expect, ret);
434
435 if (testcases[i].pkey)
436 {
437 ok(IsEqualGUID(&testcases[i].pkey->fmtid, &testcases[i].pkey_expect.fmtid),
438 "[%d] Expected GUID %s, got %s\n",
439 i, wine_dbgstr_guid(&testcases[i].pkey_expect.fmtid), wine_dbgstr_guid(&testcases[i].pkey->fmtid));
440 ok(testcases[i].pkey->pid == testcases[i].pkey_expect.pid,
441 "[%d] Expected property ID %lu, got %lu\n",
442 i, testcases[i].pkey_expect.pid, testcases[i].pkey->pid);
443 }
444 }
445}
#define U(x)
Definition: wordpad.c:45
#define expect_guid(expected, guid)
Definition: typelib.c:49
#define GUID_MEMBERS(g)
Definition: propsys.c:43
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
Definition: propsys_main.c:389
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
int ret

Referenced by START_TEST().

◆ test_PSRefreshPropertySchema()

static void test_PSRefreshPropertySchema ( void  )
static

Definition at line 447 of file propsys.c.

448{
449 HRESULT ret;
450
454 "Expected PSRefreshPropertySchema to return CO_E_NOTINITIALIZED, got 0x%08lx\n", ret);
455
457
459 ok(ret == S_OK,
460 "Expected PSRefreshPropertySchema to return S_OK, got 0x%08lx\n", ret);
461
463}
#define CO_E_NOTINITIALIZED
HRESULT WINAPI PSRefreshPropertySchema(void)
Definition: propsys_main.c:241

Referenced by START_TEST().

◆ test_PSStringFromPropertyKey()

static void test_PSStringFromPropertyKey ( void  )
static

Definition at line 59 of file propsys.c.

60{
61 static const WCHAR fillerW[] = {'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
62 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
63 'X','X','X','X','X','X','X','X','X','X'};
64 static const WCHAR zero_fillerW[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
65 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
66 'X','X','X','X','X','X','X','X','X','X','X','X','X','X'};
67 static const WCHAR zero_truncatedW[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
68 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
69 '0','0','0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
70 static const WCHAR zero_truncated2W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
71 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
72 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
73 static const WCHAR zero_truncated3W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
74 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
75 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
76 static const WCHAR zero_truncated4W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
77 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
78 '0','0','0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
79 static const WCHAR truncatedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
80 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
81 '0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
82 static const WCHAR truncated2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
83 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
84 '0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
85 static const WCHAR truncated3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
86 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
87 '0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
88 static const WCHAR truncated4W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
89 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
90 '0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
91 static const WCHAR expectedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
92 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
93 '0','}',' ','4','2','9','4','9','6','7','2','9','5',0};
94 static const WCHAR expected2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
95 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
96 '0','}',' ','1','3','5','7','9','\0','X','X','X','X','X'};
97 static const WCHAR expected3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
98 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
99 '0','}',' ','0','\0','X','X','X','X','X','X','X','X','X'};
100 PROPERTYKEY prop = {GUID_MEMBERS(GUID_NULL), ~0U};
101 PROPERTYKEY prop2 = {GUID_MEMBERS(GUID_NULL), 13579};
102 PROPERTYKEY prop3 = {GUID_MEMBERS(GUID_NULL), 0};
103 WCHAR out[PKEYSTR_MAX];
104 HRESULT ret;
105
106 const struct
107 {
108 REFPROPERTYKEY pkey;
109 LPWSTR psz;
110 UINT cch;
111 HRESULT hr_expect;
112 const WCHAR *buf_expect;
113 BOOL hr_broken;
114 HRESULT hr2;
115 BOOL buf_broken;
116 const WCHAR *buf2;
117 } testcases[] =
118 {
119 {NULL, NULL, 0, E_POINTER},
120 {&prop, NULL, 0, E_POINTER},
121 {&prop, NULL, PKEYSTR_MAX, E_POINTER},
122 {NULL, out, 0, E_NOT_SUFFICIENT_BUFFER, fillerW},
123 {NULL, out, PKEYSTR_MAX, E_NOT_SUFFICIENT_BUFFER, zero_fillerW, FALSE, 0, TRUE, fillerW},
124 {&prop, out, 0, E_NOT_SUFFICIENT_BUFFER, fillerW},
125 {&prop, out, GUIDSTRING_MAX, E_NOT_SUFFICIENT_BUFFER, fillerW},
126 {&prop, out, GUIDSTRING_MAX + 1, E_NOT_SUFFICIENT_BUFFER, fillerW},
127 {&prop, out, GUIDSTRING_MAX + 2, E_NOT_SUFFICIENT_BUFFER, zero_truncatedW, TRUE, S_OK, TRUE, truncatedW},
128 {&prop, out, PKEYSTR_MAX - 2, E_NOT_SUFFICIENT_BUFFER, zero_truncated2W, TRUE, S_OK, TRUE, truncated2W},
129 {&prop, out, PKEYSTR_MAX - 1, E_NOT_SUFFICIENT_BUFFER, zero_truncated3W, TRUE, S_OK, TRUE, truncated3W},
130 {&prop, out, PKEYSTR_MAX, S_OK, expectedW},
131 {&prop2, out, GUIDSTRING_MAX + 2, E_NOT_SUFFICIENT_BUFFER, zero_truncated4W, TRUE, S_OK, TRUE, truncated4W},
132 {&prop2, out, GUIDSTRING_MAX + 6, S_OK, expected2W},
133 {&prop2, out, PKEYSTR_MAX, S_OK, expected2W},
134 {&prop3, out, GUIDSTRING_MAX + 1, E_NOT_SUFFICIENT_BUFFER, fillerW},
135 {&prop3, out, GUIDSTRING_MAX + 2, S_OK, expected3W},
136 {&prop3, out, PKEYSTR_MAX, S_OK, expected3W},
137 };
138
139 int i;
140
141 for (i = 0; i < ARRAY_SIZE(testcases); i++)
142 {
143 if (testcases[i].psz)
144 memcpy(testcases[i].psz, fillerW, PKEYSTR_MAX * sizeof(WCHAR));
145
146 ret = PSStringFromPropertyKey(testcases[i].pkey,
147 testcases[i].psz,
148 testcases[i].cch);
149 ok(ret == testcases[i].hr_expect ||
150 broken(testcases[i].hr_broken && ret == testcases[i].hr2), /* Vista/Win2k8 */
151 "[%d] Expected PSStringFromPropertyKey to return 0x%08lx, got 0x%08lx\n",
152 i, testcases[i].hr_expect, ret);
153
154 if (testcases[i].psz)
155 ok(!memcmp(testcases[i].psz, testcases[i].buf_expect, PKEYSTR_MAX * sizeof(WCHAR)) ||
156 broken(testcases[i].buf_broken &&
157 !memcmp(testcases[i].psz, testcases[i].buf2, PKEYSTR_MAX * sizeof(WCHAR))), /* Vista/Win2k8 */
158 "[%d] Unexpected output contents\n", i);
159 }
160}
#define broken(x)
Definition: atltest.h:178
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
PROPERTYKEY * REFPROPERTYKEY
Definition: propsys.idl:40
HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch)
Definition: propsys_main.c:247
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_VariantToPropVariant()

static void test_VariantToPropVariant ( void  )
static

Definition at line 2481 of file propsys.c.

2482{
2483 PROPVARIANT propvar;
2484 VARIANT var;
2485 HRESULT hr;
2486
2487 VariantInit(&var);
2488 PropVariantInit(&propvar);
2489
2490 hr = VariantToPropVariant(NULL, &propvar);
2491 ok(hr == E_INVALIDARG, "VariantToPropVariant returned %#lx.\n", hr);
2493 ok(hr == E_INVALIDARG, "VariantToPropVariant returned %#lx.\n", hr);
2494
2495 V_VT(&var) = 0xdead;
2496 hr = VariantToPropVariant(&var, &propvar);
2497 ok(hr == DISP_E_BADVARTYPE, "VariantToPropVariant returned %#lx.\n", hr);
2498 V_VT(&var) = VT_ILLEGAL;
2499 hr = VariantToPropVariant(&var, &propvar);
2500 todo_wine
2501 ok(hr == TYPE_E_TYPEMISMATCH, "VariantToPropVariant returned %#lx.\n", hr);
2502 V_VT(&var) = VT_CLSID;
2503 hr = VariantToPropVariant(&var, &propvar);
2504 todo_wine
2505 ok(hr == DISP_E_BADVARTYPE, "VariantToPropVariant returned %#lx.\n", hr);
2506
2507 V_VT(&var) = VT_EMPTY;
2508 hr = VariantToPropVariant(&var, &propvar);
2509 ok(hr == S_OK, "VariantToPropVariant returned %#lx.\n", hr);
2510 ok(propvar.vt == VT_EMPTY, "Unexpected propvar.vt %d.\n", propvar.vt);
2511
2512 V_VT(&var) = VT_NULL;
2513 hr = VariantToPropVariant(&var, &propvar);
2514 ok(hr == S_OK, "VariantToPropVariant returned %#lx.\n", hr);
2515 ok(propvar.vt == VT_NULL, "Unexpected propvar.vt %d.\n", propvar.vt);
2516
2517 check_VariantToPropVariant(var, propvar, I1, cVal, -123, "%c");
2518 check_VariantToPropVariant(var, propvar, I2, iVal, -456, "%d");
2519 check_VariantToPropVariant(var, propvar, I4, lVal, -789, "%ld");
2520 check_VariantToPropVariant(var, propvar, I8, hVal.QuadPart, -101112, "%I64d");
2521
2522 check_VariantToPropVariant(var, propvar, UI1, bVal, 0xcd, "%#x");
2523 check_VariantToPropVariant(var, propvar, UI2, uiVal, 0xdead, "%#x");
2524 check_VariantToPropVariant(var, propvar, UI4, ulVal, 0xdeadbeef, "%#lx");
2525 check_VariantToPropVariant(var, propvar, UI8, uhVal.QuadPart, 0xdeadbeefdeadbeef, "%I64x");
2526
2527 check_VariantToPropVariant(var, propvar, BOOL, boolVal, TRUE, "%d");
2528
2529 check_VariantToPropVariant(var, propvar, R4, fltVal, 0.123f, "%f");
2530 check_VariantToPropVariant(var, propvar, R8, dblVal, 0.456f, "%f");
2531
2532 V_VT(&var) = VT_BSTR;
2533 V_BSTR(&var) = SysAllocString(L"test");
2534 hr = VariantToPropVariant(&var, &propvar);
2535 ok(hr == S_OK, "VariantToPropVariant returned %#lx.\n", hr);
2536 ok(propvar.vt == VT_BSTR, "Unexpected propvar.vt %d.\n", propvar.vt);
2537 ok(propvar.bstrVal != V_BSTR(&var), "Got same string pointer.\n");
2538 ok(!wcscmp(propvar.bstrVal, V_BSTR(&var)), "Unexpected propvar.bstrVal %s.\n", debugstr_w(propvar.bstrVal));
2539
2540 PropVariantClear(&propvar);
2541 VariantClear(&var);
2542}
#define check_VariantToPropVariant(var, propvar, type, member, value, format)
Definition: propsys.c:2459
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
#define TYPE_E_TYPEMISMATCH
Definition: winerror.h:2548

Referenced by START_TEST().

◆ test_VariantToString()

static void test_VariantToString ( void  )
static

Definition at line 2423 of file propsys.c.

2424{
2425 HRESULT hr;
2426 VARIANT v;
2427 WCHAR buff[64];
2428
2429 buff[0] = 1;
2430 V_VT(&v) = VT_EMPTY;
2431 hr = VariantToString(&v, buff, 64);
2432 todo_wine
2433 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2434 ok(!buff[0], "Unexpected buffer.\n");
2435
2436 buff[0] = 0;
2437 V_VT(&v) = VT_I4;
2438 V_I4(&v) = 567;
2439 hr = VariantToString(&v, buff, 64);
2440 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2441 ok(!wcscmp(buff, L"567"), "Unexpected buffer %s.\n", wine_dbgstr_w(buff));
2442
2443 V_VT(&v) = VT_BSTR;
2444 V_BSTR(&v) = SysAllocString(L"test1");
2445
2446 buff[0] = 1;
2447 hr = VariantToString(&v, buff, 0);
2448 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2449 ok(!buff[0], "Unexpected buffer.\n");
2450
2451 hr = VariantToString(&v, buff, 5);
2452 ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
2453 hr = VariantToString(&v, buff, 6);
2454 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2455 ok(!wcscmp(buff, L"test1"), "Unexpected string.\n");
2456 VariantClear(&v);
2457}
HRESULT WINAPI VariantToString(REFVARIANT var, PWSTR ret, UINT cch)
Definition: propvar.c:503
static unsigned char buff[32768]
Definition: fatten.c:17
const GLdouble * v
Definition: gl.h:2040
#define V_I4(A)
Definition: oleauto.h:247

Referenced by START_TEST().

◆ test_VariantToStringWithDefault()

static void test_VariantToStringWithDefault ( void  )
static

Definition at line 2237 of file propsys.c.

2238{
2239 static WCHAR default_value[] = L"test";
2240 VARIANT var, var2;
2241 PCWSTR result;
2242 BSTR b;
2243
2244 V_VT(&var) = VT_EMPTY;
2246 ok(result == NULL, "Unexpected value %s\n", wine_dbgstr_w(result));
2247 result = VariantToStringWithDefault(&var, default_value);
2248 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
2249
2250 V_VT(&var) = VT_NULL;
2252 ok(result == NULL, "Unexpected value %s\n", wine_dbgstr_w(result));
2253 result = VariantToStringWithDefault(&var, default_value);
2254 ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result));
2255
2256