2 WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n);
5 #define TST_FUNCTION wcsxfrm
7 #include "tsp_common.c"
8 #include "dat_wcsxfrm.c"
11 tst_wcsxfrm (FILE * fp
, int debug_flg
)
13 TST_DECL_VARS (size_t);
15 wchar_t frm1
[MBSSIZE
], frm2
[MBSSIZE
];
17 int ret_coll
, ret_cmp
;
21 TST_HEAD_LOCALE (wcsxfrm
, S_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
)
32 Result (C_IGNORED
, S_WCSXFRM
, CASE_9
,
33 "input data n1 or n2 is invalid");
37 /* an errno and a return value are checked
38 only for 2nd wcsxfrm() call.
39 A result of 1st call is used to compare
40 those 2 values by using wcscmp().
44 ret
= wcsxfrm (frm1
, org1
, n1
); /* First call */
49 fprintf (stdout
, "tst_wcsxfrm() : REC = %d\n", rec
+ 1);
50 fprintf (stdout
, "tst_wcsxfrm() : 1st ret = %d\n", ret
);
53 if (ret
== -1 || ret
>= n1
|| errno_save
!= 0)
56 Result (C_INVALID
, S_WCSXFRM
, CASE_8
,
57 "got an error in fist wcsxfrm() call");
63 ret
= wcsxfrm (((n2
== 0) ? NULL
: frm2
), org2
, n2
);
66 TST_IF_RETURN (S_WCSXFRM
)
70 if (n2
== 0 || ret
>= n2
|| errno
!= 0)
74 Result (C_IGNORED
, S_WCSXFRM
, CASE_7
, "did not get a result");
81 fprintf (stdout
, "tst_wcsxfrm() : 2nd ret = %d\n", ret
);
86 /* depends on wcscoll() ... not good though ... */
87 ret_coll
= wcscoll (org1
, org2
);
90 if (errno
!= 0) /* bugs * bugs may got correct results ... */
93 Result (C_INVALID
, S_WCSXFRM
, CASE_6
,
94 "got an error in wcscoll() call");
98 ret_cmp
= wcscmp (frm1
, frm2
);
100 if ((ret_coll
== ret_cmp
) || (ret_coll
> 0 && ret_cmp
> 0)
101 || (ret_coll
< 0 && ret_cmp
< 0))
103 Result (C_SUCCESS
, S_WCSXFRM
, CASE_3
,
104 MS_PASSED
" (depends on wcscoll & wcscmp)");
109 Result (C_FAILURE
, S_WCSXFRM
, CASE_3
,
110 "results from wcscoll & wcscmp() do not match");
115 fprintf (stdout
, "tst_wcsxfrm() : coll = %d <-> %d = cmp\n",