Sebastian Lackner : combase/tests: Add tests for WindowsConcatString.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Oct 29 09:32:12 CDT 2015


Module: wine
Branch: master
Commit: 55149dc2c4727ff0ee547328597d11882ef58cde
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=55149dc2c4727ff0ee547328597d11882ef58cde

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Thu Oct 29 05:07:23 2015 +0100

combase/tests: Add tests for WindowsConcatString.

Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/combase/tests/string.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c
index 7af5f7e..8e112c3 100644
--- a/dlls/combase/tests/string.c
+++ b/dlls/combase/tests/string.c
@@ -27,6 +27,7 @@
 
 #include "wine/test.h"
 
+static HRESULT (WINAPI *pWindowsConcatString)(HSTRING, HSTRING, HSTRING *);
 static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
 static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
 static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
@@ -51,6 +52,7 @@ static BOOL init_functions(void)
         win_skip("Failed to load combase.dll, skipping tests\n");
         return FALSE;
     }
+    SET(WindowsConcatString);
     SET(WindowsCreateString);
     SET(WindowsCreateStringReference);
     SET(WindowsDeleteString);
@@ -94,6 +96,8 @@ static void _check_string(int line, HSTRING str, LPCWSTR content, UINT32 length,
 }
 
 static const WCHAR input_string[] = { 'a', 'b', 'c', 'd', 'e', 'f', '\0', '\0' };
+static const WCHAR input_string1[] = { 'a', 'b', 'c', '\0' };
+static const WCHAR input_string2[] = { 'd', 'e', 'f', '\0' };
 static const WCHAR input_empty_string[] = { '\0' };
 static const WCHAR input_embed_null[] = { 'a', '\0', 'c', '\0', 'e', 'f', '\0' };
 static const WCHAR output_substring[] = { 'c', 'd', 'e', 'f', '\0' };
@@ -334,6 +338,62 @@ static void test_substring(void)
     ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
 }
 
+static void test_concat(void)
+{
+    HSTRING str1, str2, concat;
+    HSTRING_HEADER header1, header2;
+
+    /* Test concatenation 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(pWindowsConcatString(str1, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+    ok(pWindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+    ok(str1 == concat, "Concatenate created new string\n");
+    check_string(concat, input_string1, 3, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsConcatString(NULL, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+    ok(pWindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
+    ok(str2 == concat, "Concatenate created new string\n");
+    check_string(concat, input_string2, 3, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsConcatString(str1, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+    ok(pWindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
+    check_string(concat, input_string, 6, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+    ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
+
+    /* Test concatenation 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(pWindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+    ok(str1 != concat, "Concatenate string ref didn't create new string\n");
+    check_string(concat, input_string1, 3, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
+    ok(str2 != concat, "Concatenate string ref didn't create new string\n");
+    check_string(concat, input_string2, 3, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
+    check_string(concat, input_string, 6, FALSE);
+    ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+
+    ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+    ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
+
+    /* Test concatenation of two empty strings */
+    ok(pWindowsConcatString(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+    ok(pWindowsConcatString(NULL, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+    ok(concat == NULL, "Concatenate created new string\n");
+}
+
 START_TEST(string)
 {
     if (!init_functions())
@@ -343,4 +403,5 @@ START_TEST(string)
     test_access();
     test_string_buffer();
     test_substring();
+    test_concat();
 }




More information about the wine-cvs mailing list