1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*============================================================================
**
** Source: test1.c
**
** Purpose:
** Tests that wcsncat correctly appends wide strings, making sure it handles
** count argument correctly (appending no more than count characters, always
** placing a null, and padding the string if necessary).
**
**
**==========================================================================*/
#include <palsuite.h>
int __cdecl main(int argc, char *argv[])
{
WCHAR dest[80];
WCHAR test[] = {'f','o','o',' ','b','a','r','b','a','z',0};
WCHAR str1[] = {'f','o','o',' ',0};
WCHAR str2[] = {'b','a','r',' ',0};
WCHAR str3[] = {'b','a','z',0};
WCHAR *ptr;
int i;
if (PAL_Initialize(argc, argv))
{
return FAIL;
}
dest[0] = 0;
for (i=1; i<80; i++)
{
dest[i] = (WCHAR)'x';
}
ptr = wcsncat(dest, str1, wcslen(str1));
if (ptr != dest)
{
Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr);
}
ptr = wcsncat(dest, str2, 3);
if (ptr != dest)
{
Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr);
}
if (dest[7] != 0)
{
Fail("ERROR: wcsncat did not place a terminating NULL!");
}
ptr = wcsncat(dest, str3, 20);
if (ptr != dest)
{
Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr);
}
if (wcscmp(dest, test) != 0)
{
Fail("ERROR: Expected wcsncat to give \"%S\", got \"%S\"\n",
test, dest);
}
if (dest[wcslen(test)+1] != (WCHAR)'x')
{
Fail("wcsncat went out of bounds!\n");
}
PAL_Terminate();
return PASS;
}
|