]> git.ipfire.org Git - thirdparty/glibc.git/blob - localedata/tests-mbwc/tst_wcscpy.c
Update.
[thirdparty/glibc.git] / localedata / tests-mbwc / tst_wcscpy.c
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
9 int
10 tst_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 (ws1, 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 (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
45 {
46 if (debug_flg)
47 {
48 fprintf (stderr,
49 "ws1[ %d ] = 0x%lx <-> wx_ex[ %d ] = 0x%lx\n", i,
50 ws1[i], i, ws_ex[i]);
51 }
52
53 if (ws1[i] != ws_ex[i])
54 {
55 err++;
56 err_count++;
57 Result (C_FAILURE, S_WCSCPY, CASE_4,
58 "copied string is different from an"
59 " expected string");
60 break;
61 }
62 }
63
64 if (!err)
65 {
66 Result (C_SUCCESS, S_WCSCPY, CASE_4, MS_PASSED);
67 }
68
69 if (ws1[i] == 0L)
70 {
71 Result (C_SUCCESS, S_WCSCPY, CASE_5, MS_PASSED);
72 }
73 else
74 {
75 err_count++;
76 Result (C_FAILURE, S_WCSCPY, CASE_5,
77 "copied string is not null-terminated");
78 }
79 }
80 }
81 }
82
83 return err_count;
84 }