scripts/glibcelf.py: Add PT_AARCH64_MEMTAG_MTE constant
[glibc.git] / localedata / tests-mbwc / tst_wcsxfrm.c
blobce22844a54498bea143646f4390d09818d66b3f8
1 /*
2 WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n);
3 */
5 #define TST_FUNCTION wcsxfrm
7 #include "tsp_common.c"
8 #include "dat_wcsxfrm.c"
10 int
11 tst_wcsxfrm (FILE * fp, int debug_flg)
13 TST_DECL_VARS (size_t);
14 wchar_t *org1, *org2;
15 wchar_t frm1[MBSSIZE], frm2[MBSSIZE];
16 size_t n1, n2;
17 int ret_coll, ret_cmp;
19 TST_DO_TEST (wcsxfrm)
21 TST_HEAD_LOCALE (wcsxfrm, S_WCSXFRM);
22 TST_DO_REC (wcsxfrm)
24 TST_GET_ERRET (wcsxfrm);
25 org1 = TST_INPUT (wcsxfrm).org1;
26 org2 = TST_INPUT (wcsxfrm).org2;
27 n1 = TST_INPUT (wcsxfrm).n1;
28 n2 = TST_INPUT (wcsxfrm).n2;
29 if (n1 < 0 || sizeof (frm1) < n1 || sizeof (frm2) < n2)
31 Result (C_IGNORED, S_WCSXFRM, CASE_9,
32 "input data n1 or n2 is invalid");
33 continue;
36 /* an errno and a return value are checked
37 only for 2nd wcsxfrm() call.
38 A result of 1st call is used to compare
39 those 2 values by using wcscmp().
42 TST_CLEAR_ERRNO;
43 ret = wcsxfrm (frm1, org1, n1); /* First call */
44 TST_SAVE_ERRNO;
46 if (debug_flg)
48 fprintf (stdout, "tst_wcsxfrm() : REC = %d\n", rec + 1);
49 fprintf (stdout, "tst_wcsxfrm() : 1st ret = %zu\n", ret);
52 if (ret == -1 || ret >= n1 || errno_save != 0)
54 Result (C_INVALID, S_WCSXFRM, CASE_8,
55 "got an error in fist wcsxfrm() call");
56 continue;
59 TST_CLEAR_ERRNO;
60 /* Second call */
61 ret = wcsxfrm (((n2 == 0) ? NULL : frm2), org2, n2);
62 TST_SAVE_ERRNO;
64 TST_IF_RETURN (S_WCSXFRM)
68 if (n2 == 0 || ret >= n2 || errno != 0)
70 #if 0
71 Result (C_IGNORED, S_WCSXFRM, CASE_7, "did not get a result");
72 #endif
73 continue;
76 if (debug_flg)
78 fprintf (stdout, "tst_wcsxfrm() : 2nd ret = %zu\n", ret);
81 /* wcscoll() */
82 TST_CLEAR_ERRNO;
83 /* depends on wcscoll() ... not good though ... */
84 ret_coll = wcscoll (org1, org2);
85 TST_SAVE_ERRNO;
87 if (errno != 0) /* bugs * bugs may got correct results ... */
89 Result (C_INVALID, S_WCSXFRM, CASE_6,
90 "got an error in wcscoll() call");
91 continue;
93 /* wcscmp() */
94 ret_cmp = wcscmp (frm1, frm2);
96 if ((ret_coll == ret_cmp) || (ret_coll > 0 && ret_cmp > 0)
97 || (ret_coll < 0 && ret_cmp < 0))
99 Result (C_SUCCESS, S_WCSXFRM, CASE_3,
100 MS_PASSED " (depends on wcscoll & wcscmp)");
102 else
104 err_count++;
105 Result (C_FAILURE, S_WCSXFRM, CASE_3,
106 "results from wcscoll & wcscmp() do not match");
109 if (debug_flg)
111 fprintf (stdout, "tst_wcsxfrm() : coll = %d <-> %d = cmp\n",
112 ret_coll, ret_cmp);
117 return err_count;