combase/tests: Add tests for WindowsCompareStringOrdinal.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2016-02-10 23:25:48 +01:00 committed by Alexandre Julliard
parent e39405d44d
commit f3827dab8f
1 changed files with 63 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "wine/test.h"
static HRESULT (WINAPI *pWindowsCompareStringOrdinal)(HSTRING, HSTRING, INT32 *);
static HRESULT (WINAPI *pWindowsConcatString)(HSTRING, HSTRING, HSTRING *);
static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
@ -52,6 +53,7 @@ static BOOL init_functions(void)
win_skip("Failed to load combase.dll, skipping tests\n");
return FALSE;
}
SET(WindowsCompareStringOrdinal);
SET(WindowsConcatString);
SET(WindowsCreateString);
SET(WindowsCreateStringReference);
@ -394,6 +396,66 @@ static void test_concat(void)
ok(concat == NULL, "Concatenate created new string\n");
}
static void test_compare(void)
{
HSTRING str1, str2;
HSTRING_HEADER header1, header2;
INT32 res;
/* Test comparison of string buffers */
ok(pWindowsCreateString(input_string1, 3, &str1) == S_OK, "Failed to create string\n");
ok(pWindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
ok(pWindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
/* Test comparison of string references */
ok(pWindowsCreateStringReference(input_string1, 3, &header1, &str1) == S_OK, "Failed to create string ref\n");
ok(pWindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
ok(pWindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
ok(pWindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
/* Test comparison of two empty strings */
ok(pWindowsCompareStringOrdinal(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
ok(pWindowsCompareStringOrdinal(NULL, NULL, &res) == S_OK, "Failed to compare NULL string\n");
ok(res == 0, "Expected 0, got %d\n", res);
}
START_TEST(string)
{
if (!init_functions())
@ -404,4 +466,5 @@ START_TEST(string)
test_string_buffer();
test_substring();
test_concat();
test_compare();
}