1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*============================================================================ |
6 | ** |
7 | ** Source: test1.c |
8 | ** |
9 | ** Purpose: |
10 | ** Test to that wcscat correctly concatanates wide strings, including placing |
11 | ** null pointers. |
12 | ** |
13 | ** |
14 | **==========================================================================*/ |
15 | |
16 | |
17 | |
18 | #include <palsuite.h> |
19 | |
20 | /* |
21 | * Notes: uses memcmp and the (pal) sprintf_s |
22 | */ |
23 | |
24 | int __cdecl main(int argc, char *argv[]) |
25 | { |
26 | WCHAR dest[80]; |
27 | WCHAR test[] = {'f','o','o',' ','b','a','r',' ','b','a','z',0}; |
28 | WCHAR str1[] = {'f','o','o',' ',0}; |
29 | WCHAR str2[] = {'b','a','r',' ',0}; |
30 | WCHAR str3[] = {'b','a','z',0}; |
31 | WCHAR *ptr; |
32 | char buffer[256]; |
33 | |
34 | |
35 | if (PAL_Initialize(argc, argv)) |
36 | { |
37 | return FAIL; |
38 | } |
39 | |
40 | |
41 | dest[0] = 0; |
42 | |
43 | ptr = wcscat(dest, str1); |
44 | if (ptr != dest) |
45 | { |
46 | Fail("ERROR: Expected wcscat to return ptr to %p, got %p" , dest, ptr); |
47 | } |
48 | |
49 | ptr = wcscat(dest, str2); |
50 | if (ptr != dest) |
51 | { |
52 | Fail("ERROR: Expected wcscat to return ptr to %p, got %p" , dest, ptr); |
53 | } |
54 | |
55 | ptr = wcscat(dest, str3); |
56 | if (ptr != dest) |
57 | { |
58 | Fail("ERROR: Expected wcscat to return ptr to %p, got %p" , dest, ptr); |
59 | } |
60 | |
61 | if (memcmp(dest, test, sizeof(test)) != 0) |
62 | { |
63 | sprintf_s(buffer, _countof(buffer), "%S" , dest); |
64 | Fail("ERROR: Expected wcscat to give \"%s\", got \"%s\"\n" , |
65 | "foo bar baz" , buffer); |
66 | } |
67 | |
68 | PAL_Terminate(); |
69 | return PASS; |
70 | } |
71 | |
72 | |