vbscript: Implement StrComp().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
83af2eec50
commit
5c6aa8d6c3
|
@ -1027,10 +1027,41 @@ static HRESULT Global_MidB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
||||
static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
BSTR left, right;
|
||||
int mode, ret;
|
||||
HRESULT hres;
|
||||
short val;
|
||||
|
||||
TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
|
||||
|
||||
assert(args_cnt == 2 || args_cnt == 3);
|
||||
|
||||
if(V_VT(args) != VT_BSTR || V_VT(args+1) != VT_BSTR) {
|
||||
FIXME("args[0] = %s, args[1] = %s\n", debugstr_variant(args), debugstr_variant(args+1));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (args_cnt == 3) {
|
||||
hres = to_int(args+2, &mode);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if (mode != 0 && mode != 1) {
|
||||
FIXME("unknown compare mode = %d\n", mode);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
mode = 0;
|
||||
|
||||
left = V_BSTR(args);
|
||||
right = V_BSTR(args+1);
|
||||
|
||||
ret = mode ? strcmpiW(left, right) : strcmpW(left, right);
|
||||
val = ret < 0 ? -1 : (ret > 0 ? 1 : 0);
|
||||
return return_short(res, val);
|
||||
}
|
||||
|
||||
static HRESULT Global_LCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
||||
|
|
|
@ -440,6 +440,26 @@ TestLCase 0.123, doubleAsString(0.123)
|
|||
TestLCase Empty, ""
|
||||
Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
|
||||
|
||||
Sub TestStrComp(str_left, str_right, mode, ex)
|
||||
x = StrComp(str_left, str_right, mode)
|
||||
Call ok(x = ex, "StrComp(" & str_left & ", " & str_right & ", " & mode & ") = " & x & " expected " & ex)
|
||||
End Sub
|
||||
|
||||
TestStrComp "ABC", "abc", 0, -1
|
||||
TestStrComp "abc", "ABC", 0, 1
|
||||
TestStrComp "ABC", "ABC", 0, 0
|
||||
TestStrComp "ABC", "abc", 0, -1
|
||||
TestStrComp "abc", "ABC", 0, 1
|
||||
TestStrComp "ABC", "ABC", 0, 0
|
||||
TestStrComp "ABCD", "ABC", 0, 1
|
||||
TestStrComp "ABC", "ABCD", 0, -1
|
||||
TestStrComp "ABC", "abc", 1, 0
|
||||
TestStrComp "ABC", "ABC", 1, 0
|
||||
TestStrComp "ABCD", "ABC", 1, 1
|
||||
TestStrComp "ABC", "ABCD", 1, -1
|
||||
TestStrComp "ABC", "ABCD", "0", -1
|
||||
TestStrComp "ABC", "ABCD", "1", -1
|
||||
|
||||
Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
|
||||
Call ok(Len("") = 0, "Len() = " & Len(""))
|
||||
Call ok(Len(1) = 1, "Len(1) = " & Len(1))
|
||||
|
|
Loading…
Reference in New Issue