2 WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2, size_t n);
5 #define TST_FUNCTION wcsncpy
7 #include "tsp_common.c"
8 #include "dat_wcsncpy.c"
13 tst_wcsncpy (FILE *fp
, int debug_flg
)
15 TST_DECL_VARS (wchar_t *);
16 wchar_t ws1
[WCSSIZE
] =
17 { 0x9999, 0x9999, 0x9999, 0x9999, 0x9999, 0x9999, 0x0000 };
24 TST_HEAD_LOCALE (wcsncpy
, S_WCSNCPY
);
27 TST_GET_ERRET (wcsncpy
);
29 for (n
= 0; n
< WCSNUM_NCPY
- 1; ++n
)
35 ws2
= TST_INPUT (wcsncpy
).ws
; /* external value: size WCSSIZE */
36 n
= TST_INPUT (wcsncpy
).n
;
37 ret
= wcsncpy (ws1
, ws2
, n
);
39 TST_IF_RETURN (S_WCSNCPY
)
43 Result (C_SUCCESS
, S_WCSNCPY
, CASE_3
, MS_PASSED
);
48 Result (C_FAILURE
, S_WCSNCPY
, CASE_3
,
49 "the return address may not be correct");
57 fprintf (stderr
, "\nwcsncpy: n = %zu\n\n", n
);
60 ws_ex
= TST_EXPECT (wcsncpy
).ws
;
62 for (err
= 0, i
= 0; i
< WCSNUM_NCPY
&& i
< WCSSIZE
; i
++)
66 "wcsncpy: ws1[ %d ] = 0x%lx <-> wx_ex[ %d ] = 0x%lx\n",
67 i
, (unsigned long int) ws1
[i
], i
,
68 (unsigned long int) ws_ex
[i
]);
70 if (ws1
[i
] != ws_ex
[i
])
74 Result (C_FAILURE
, S_WCSNCPY
, CASE_4
,
75 "copied string is different from an "
83 Result (C_SUCCESS
, S_WCSNCPY
, CASE_4
, MS_PASSED
);
86 /* A null terminate character is not supposed to be copied
87 unless (num chars of ws2)<n. */