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: Tests that wcscpy correctly copies a null-terminated wide string.
10**
11**
12**==========================================================================*/
13
14
15#include <palsuite.h>
16
17/*
18 * Notes: uses memcmp and sprintf_s.
19 */
20
21int __cdecl main(int argc, char *argv[])
22{
23 WCHAR str[] = {'f','o','o',0,'b','a','r',0};
24 WCHAR dest[80];
25 WCHAR result[] = {'f','o','o',0};
26 WCHAR *ret;
27 char buffer[256];
28
29
30 if (PAL_Initialize(argc, argv))
31 {
32 return FAIL;
33 }
34
35
36 ret = wcscpy(dest, str);
37
38 if (ret != dest || memcmp(dest, result, sizeof(result)) != 0)
39 {
40 sprintf_s(buffer, _countof(buffer), "%S", dest);
41 Fail("Expected wcscpy to give \"%s\" with a return value of %p, got \"%s\" "
42 "with a return value of %p.\n", "foo", dest, buffer, ret);
43 }
44
45 PAL_Terminate();
46 return PASS;
47}
48