iconv mapping of 0xA8 0xEC in CP1258 is non-canonical
[glibc.git] / localedata / tests-mbwc / tst_wcsncpy.c
blob814bbc0a8bcfabfc73713ef5d4d92abf3e3e2294
1 /*
2 WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2, size_t n);
3 */
5 #define TST_FUNCTION wcsncpy
7 #include "tsp_common.c"
8 #include "dat_wcsncpy.c"
10 #define WCSNUM_NCPY 7
12 int
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 };
18 wchar_t *ws2, *ws_ex;
19 int err, i;
20 size_t n;
22 TST_DO_TEST (wcsncpy)
24 TST_HEAD_LOCALE (wcsncpy, S_WCSNCPY);
25 TST_DO_REC (wcsncpy)
27 TST_GET_ERRET (wcsncpy);
29 for (n = 0; n < WCSNUM_NCPY - 1; ++n)
31 ws1[n] = 0x9999;
34 ws1[n] = 0;
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)
41 if (ret == ws1)
43 Result (C_SUCCESS, S_WCSNCPY, CASE_3, MS_PASSED);
45 else
47 err_count++;
48 Result (C_FAILURE, S_WCSNCPY, CASE_3,
49 "the return address may not be correct");
53 if (ret == ws1)
55 if (debug_flg)
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++)
64 if (debug_flg)
65 fprintf (stderr,
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])
72 err++;
73 err_count++;
74 Result (C_FAILURE, S_WCSNCPY, CASE_4,
75 "copied string is different from an "
76 "expected string");
77 break;
81 if (!err)
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. */
92 return err_count;