Commit c395ae56 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32: Basic parameter validation tests for some GetTypeInfo* methods.

parent 18a71522
......@@ -502,10 +502,31 @@ static void test_TypeInfo(void)
DISPPARAMS dispparams;
GUID bogusguid = {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
VARIANT var;
UINT count;
TYPEKIND kind;
hr = LoadTypeLib(wszStdOle2, &pTypeLib);
ok_ole_success(hr, LoadTypeLib);
count = ITypeLib_GetTypeInfoCount(pTypeLib);
ok(count > 0, "got %d\n", count);
/* invalid index */
hr = ITypeLib_GetTypeInfo(pTypeLib, count, &pTypeInfo);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
hr = ITypeLib_GetTypeInfo(pTypeLib, 0, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = ITypeLib_GetTypeInfoType(pTypeLib, count, &kind);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
hr = ITypeLib_GetTypeInfoType(pTypeLib, count, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = ITypeLib_GetTypeInfoType(pTypeLib, 0, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pTypeInfo);
ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
......@@ -1307,6 +1328,7 @@ static void test_CreateTypeLib(void) {
int impltypeflags;
VARIANT cust_data;
HRESULT hres;
TYPEKIND kind;
trace("CreateTypeLib tests\n");
......@@ -1328,6 +1350,18 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeLib_QueryInterface(createtl, &IID_ITypeLib, (void**)&tl);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeLib_GetTypeInfo(tl, 0, NULL);
ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
hres = ITypeLib_GetTypeInfoType(tl, 0, &kind);
ok(hres == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hres);
hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
hres = ITypeLib_GetLibAttr(tl, &libattr);
ok(hres == S_OK, "got %08x\n", hres);
......
......@@ -4278,13 +4278,13 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType(
UINT i;
ITypeInfoImpl *pTInfo = This->pTypeInfo;
if (ITypeLib2_fnGetTypeInfoCount(iface) < index + 1)
return TYPE_E_ELEMENTNOTFOUND;
TRACE("(%p) index %d\n", This, index);
TRACE("(%p, %d, %p)\n", This, index, pTKind);
if(!pTKind) return E_INVALIDARG;
if(ITypeLib2_GetTypeInfoCount(iface) <= index)
return TYPE_E_ELEMENTNOTFOUND;
/* search element n in list */
for(i=0; i < index; i++)
{
......
......@@ -4862,6 +4862,8 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfo(
TRACE("(%p,%d,%p)\n", iface, index, ppTInfo);
if (!ppTInfo) return E_INVALIDARG;
if (index >= This->typelib_header.nrtypeinfos) {
return TYPE_E_ELEMENTNOTFOUND;
}
......@@ -4877,17 +4879,19 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfo(
static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType(
ITypeLib2 * iface,
UINT index,
TYPEKIND* pTKind)
TYPEKIND* kind)
{
ICreateTypeLib2Impl *This = impl_from_ITypeLib2(iface);
TRACE("(%p,%d,%p)\n", iface, index, pTKind);
TRACE("(%p,%d,%p)\n", iface, index, kind);
if (!kind) return E_INVALIDARG;
if (index >= This->typelib_header.nrtypeinfos) {
return TYPE_E_ELEMENTNOTFOUND;
}
*pTKind = (This->typelib_segment_data[MSFT_SEG_TYPEINFO][This->typelib_typeinfo_offsets[index]]) & 15;
*kind = (This->typelib_segment_data[MSFT_SEG_TYPEINFO][This->typelib_typeinfo_offsets[index]]) & 0xF;
return S_OK;
}
......
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