1/*-------------------------------------------------------------------------------------*/
2/* WCSCPY: wchar_t *wcscpy( wchar_t *ws1, const wchar_t *ws2 ) */
3/*-------------------------------------------------------------------------------------*/
4#define TST_FUNCTION wcscpy
5
6#include "tsp_common.c"
7#include "dat_wcscpy.c"
8
9int
10tst_wcscpy (FILE * fp, int debug_flg)
11{
12 TST_DECL_VARS (wchar_t *);
13 wchar_t ws1[WCSSIZE], *ws2, *ws_ex;
14 int err, i;
15
16 TST_DO_TEST (wcscpy)
17 {
18 TST_HEAD_LOCALE (wcscpy, S_WCSCPY);
19 TST_DO_REC (wcscpy)
20 {
21 TST_GET_ERRET (wcscpy);
22 ws2 = TST_INPUT (wcscpy).ws; /* external value: size WCSSIZE */
23 ret = wcscpy (dest: ws1, src: ws2);
24
25 TST_IF_RETURN (S_WCSCPY)
26 {
27 if (ret == ws1)
28 {
29 Result (C_SUCCESS, S_WCSCPY, CASE_3, MS_PASSED);
30 }
31 else
32 {
33 err_count++;
34 Result (C_FAILURE, S_WCSCPY, CASE_3,
35 "the return address may not be correct");
36 }
37 }
38
39 if (ret == ws1)
40 {
41 ws_ex = TST_EXPECT (wcscpy).ws;
42
43 for (err = 0, i = 0;
44 i < WCSSIZE && (ws1[i] != 0L || ws_ex[i] != 0L); i++)
45 {
46 if (debug_flg)
47 {
48 fprintf (stderr,
49 "ws1[ %d ] = 0x%lx <-> wx_ex[ %d ] = 0x%lx\n", i,
50 (unsigned long int) ws1[i], i,
51 (unsigned long int) ws_ex[i]);
52 }
53
54 if (ws1[i] != ws_ex[i])
55 {
56 err++;
57 err_count++;
58 Result (C_FAILURE, S_WCSCPY, CASE_4,
59 "copied string is different from an"
60 " expected string");
61 break;
62 }
63 }
64
65 if (!err)
66 {
67 Result (C_SUCCESS, S_WCSCPY, CASE_4, MS_PASSED);
68 }
69
70 if (ws1[i] == 0L)
71 {
72 Result (C_SUCCESS, S_WCSCPY, CASE_5, MS_PASSED);
73 }
74 else
75 {
76 err_count++;
77 Result (C_FAILURE, S_WCSCPY, CASE_5,
78 "copied string is not null-terminated");
79 }
80 }
81 }
82 }
83
84 return err_count;
85}
86

source code of glibc/localedata/tests-mbwc/tst_wcscpy.c