Commit 6ee95c77 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

oleaut32: Correctly test VARIANT_BOOL value in VarCat.

parent bf4b8691
......@@ -345,6 +345,20 @@ static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT
VariantClear( &result );
}
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf));
return lstrcmpW(strw, buf);
}
#define test_bstr_var(a,b) _test_bstr_var(__LINE__,a,b)
static void _test_bstr_var(unsigned line, const VARIANT *v, const char *str)
{
ok_(__FILE__,line)(V_VT(v) == VT_BSTR, "unexpected vt=%d\n", V_VT(v));
if(V_VT(v) == VT_BSTR)
ok(!strcmp_wa(V_BSTR(v), str), "v=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), str);
}
static void test_VariantInit(void)
{
......@@ -5645,6 +5659,30 @@ static void test_VarCat(void)
VariantClear(&right);
VariantClear(&result);
VariantClear(&expected);
/* Test boolean conversion */
V_VT(&left) = VT_BOOL;
V_BOOL(&left) = VARIANT_TRUE;
V_VT(&right) = VT_BSTR;
V_BSTR(&right) = SysAllocStringLen(NULL,0);
hres = VarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres);
if(!strcmp_wa(V_BSTR(&result), "True")) {
V_VT(&right) = VT_BOOL;
V_BOOL(&right) = 100;
hres = VarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres);
test_bstr_var(&result, "TrueTrue");
VariantClear(&result);
V_BOOL(&right) = VARIANT_FALSE;
hres = VarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres);
test_bstr_var(&result, "TrueFalse");
VariantClear(&result);
}else {
skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result)));
}
}
static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
......
......@@ -2624,7 +2624,7 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out)
{
/* Bools are handled as localized True/False strings instead of 0/-1 as in MSDN */
V_VT(&bstrvar_left) = VT_BSTR;
if (V_BOOL(left) == TRUE)
if (V_BOOL(left))
V_BSTR(&bstrvar_left) = SysAllocString(str_true);
else
V_BSTR(&bstrvar_left) = SysAllocString(str_false);
......@@ -2664,7 +2664,7 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out)
{
/* Bools are handled as localized True/False strings instead of 0/-1 as in MSDN */
V_VT(&bstrvar_right) = VT_BSTR;
if (V_BOOL(right) == TRUE)
if (V_BOOL(right))
V_BSTR(&bstrvar_right) = SysAllocString(str_true);
else
V_BSTR(&bstrvar_right) = SysAllocString(str_false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment