oleaut32: Added some SysFreeString tests.

This commit is contained in:
Jacek Caban 2013-02-13 18:57:38 +01:00 committed by Alexandre Julliard
parent ed9d78d2b9
commit 16d1b3b026
1 changed files with 43 additions and 0 deletions

View File

@ -6072,6 +6072,47 @@ static void test_ChangeType_keep_dst(void)
SysFreeString(bstr);
}
/* This tests assumes an empty cache, so it needs to be ran early in the test. */
static void test_bstr_cache(void)
{
BSTR str, str2, strs[20];
unsigned i;
static const WCHAR testW[] = {'t','e','s','t',0};
str = SysAllocString(testW);
/* This should put the string into cache */
SysFreeString(str);
/* The string is in cache, this won't touch it */
SysFreeString(str);
ok(SysStringLen(str) == 4, "unexpected len\n");
ok(!lstrcmpW(str, testW), "string changed\n");
str2 = SysAllocString(testW);
ok(str == str2, "str != str2\n");
SysFreeString(str2);
/* Fill the bucket with cached entries. */
for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
strs[i] = SysAllocStringLen(NULL, 24);
for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
SysFreeString(strs[i]);
/* Following allocation will be made from cache */
str = SysAllocStringLen(NULL, 24);
ok(str == strs[0], "str != strs[0]\n");
/* Smaller buffers may also use larget cached buffers */
str2 = SysAllocStringLen(NULL, 16);
ok(str2 == strs[1], "str2 != strs[1]\n");
SysFreeString(str);
SysFreeString(str2);
SysFreeString(str);
SysFreeString(str2);
}
START_TEST(vartype)
{
hOleaut32 = GetModuleHandleA("oleaut32.dll");
@ -6079,6 +6120,8 @@ START_TEST(vartype)
trace("LCIDs: System=0x%08x, User=0x%08x\n", GetSystemDefaultLCID(),
GetUserDefaultLCID());
test_bstr_cache();
test_VarI1FromI2();
test_VarI1FromI4();
test_VarI1FromI8();