]> git.ipfire.org Git - thirdparty/glibc.git/blob - localedata/tests-mbwc/tst_towctrans.c
Update.
[thirdparty/glibc.git] / localedata / tests-mbwc / tst_towctrans.c
1 /*
2 TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc);
3 */
4
5 #define TST_FUNCTION towctrans
6
7 #include "tsp_common.c"
8 #include "dat_towctrans.c"
9
10
11 int
12 tst_towctrans (FILE *fp, int debug_flg)
13 {
14 TST_DECL_VARS (wint_t);
15 wint_t wc;
16 const char *ts;
17 #if SHOJI_IS_RIGHT
18 int dummy=0;
19 #endif
20 wctrans_t wto;
21
22 TST_DO_TEST (towctrans)
23 {
24 TST_HEAD_LOCALE (towctrans, S_TOWCTRANS);
25 TST_DO_REC (towctrans)
26 {
27 TST_GET_ERRET (towctrans);
28 wc = TST_INPUT (towctrans).wc;
29 ts = TST_INPUT (towctrans).ts;
30
31 #if SHOJI_IS_RIGHT
32 if ((wto = wctrans (ts)) == (wctrans_t) 0)
33 {
34 #if 0
35 result (fp, C_IGNORED, S_TOWCTRANS, locale, rec+1, seq_num+1, 3,
36 "Skip this data because the wctrans object is not invalid.");
37 warn_count++;
38 continue;
39 #else
40 wto = &dummy; /* not good ... */
41 #endif
42 if (debug_flg)
43 {
44 fprintf (stdout, "towctrans() ------ wctrans() returnd 0.\n");
45 }
46 }
47 #else
48 wto = wctrans (ts);
49 #endif
50
51 TST_CLEAR_ERRNO;
52 ret = towctrans (wc, wto);
53 TST_SAVE_ERRNO;
54
55 if (debug_flg)
56 {
57 fprintf (stdout, "towctrans() [ %s : %d ] ret = 0x%x\n",
58 locale, rec+1, ret);
59 fprintf (stdout, " errno = %d\n",
60 errno_save);
61 }
62
63 TST_IF_RETURN (S_TOWCTRANS)
64 {
65 if (ret != 0)
66 {
67 result (fp, C_SUCCESS, S_TOWCTRANS, locale, rec+1,
68 seq_num+1, 3, MS_PASSED);
69 }
70 else
71 {
72 err_count++;
73 result (fp, C_FAILURE, S_TOWCTRANS, locale, rec+1,
74 seq_num+1, 3,
75 "the function returned 0, but should be non-zero");
76 }
77 }
78 }
79 }
80
81 return err_count;
82 }