Don't assume that $(inst_zonedir) is a subdir of $(inst_datadir).
[glibc/pb-stable.git] / localedata / tests-mbwc / tst_wcsncpy.c
blobf2127d4a7dd361eed621df980fd093a053eff08f
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 = %d\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, ws1[i], i, ws_ex[i]);
69 if (ws1[i] != ws_ex[i])
71 err++;
72 err_count++;
73 Result (C_FAILURE, S_WCSNCPY, CASE_4,
74 "copied string is different from an "
75 "expected string");
76 break;
80 if (!err)
82 Result (C_SUCCESS, S_WCSNCPY, CASE_4, MS_PASSED);
85 /* A null terminate character is not supposed to be copied
86 unless (num chars of ws2)<n. */
91 return err_count;