Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- dlls/propsys/tests/propsys.c | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index 124b3405bcb..0ba812da892 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -2064,6 +2064,59 @@ static void test_InitVariantFromFileTime(void) ok(V_DATE(&var) == d, "got wrong value: %f, expected %f\n", V_DATE(&var), d); }
+static void test_VariantToStringWithDefault(void) +{ + static WCHAR default_value[] = {'t', 'e', 's', 't', 0}; + static WCHAR wstr_test2[] = {'t', 'e', 's', 't', '2', 0}; + static WCHAR wstr_empty[] = {0}; + static WCHAR wstr_space[] = {' ', 0}; + LPCWSTR result; + VARIANT var; + + V_VT(&var) = VT_EMPTY; + result = VariantToStringWithDefault(&var, default_value); + ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result)); + + V_VT(&var) = VT_NULL; + result = VariantToStringWithDefault(&var, default_value); + ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result)); + + V_VT(&var) = VT_BOOL; + V_BOOL(&var) = VARIANT_TRUE; + result = VariantToStringWithDefault(&var, default_value); + ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result)); + + V_VT(&var) = VT_I4; + V_I4(&var) = 15; + result = VariantToStringWithDefault(&var, default_value); + ok(result == default_value, "Unexpected value %s\n", wine_dbgstr_w(result)); + + /* VT_BSTR */ + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = NULL; + result = VariantToStringWithDefault(&var, default_value); + ok(!lstrcmpW(result, wstr_empty), "Unexpected value %s\n", wine_dbgstr_w(result)); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(wstr_empty); + result = VariantToStringWithDefault(&var, default_value); + ok(!lstrcmpW(result, wstr_empty), "Unexpected value %s\n", wine_dbgstr_w(result)); + SysFreeString(V_BSTR(&var)); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(wstr_space); + result = VariantToStringWithDefault(&var, default_value); + ok(!lstrcmpW(result, wstr_space), "Unexpected value %s\n", wine_dbgstr_w(result)); + SysFreeString(V_BSTR(&var)); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(wstr_test2); + result = VariantToStringWithDefault(&var, default_value); + ok(!lstrcmpW(result, wstr_test2), "Unexpected value %s\n", wine_dbgstr_w(result)); + SysFreeString(V_BSTR(&var)); +} + START_TEST(propsys) { test_PSStringFromPropertyKey(); @@ -2088,4 +2141,5 @@ START_TEST(propsys) test_propertystore(); test_PSCreatePropertyStoreFromObject(); test_InitVariantFromFileTime(); + test_VariantToStringWithDefault(); }