PowerPC: Suppress unnecessary FPSCR write
[glibc.git] / localedata / tests-mbwc / tst_mbrtowc.c
blobffb33ce11e1d72b76db45939139f38c151b95613
1 /*
2 MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n,
3 mbstate_t *ps)
4 */
6 #define TST_FUNCTION mbrtowc
8 #include "tsp_common.c"
9 #include "dat_mbrtowc.c"
12 int
13 tst_mbrtowc (FILE * fp, int debug_flg)
15 TST_DECL_VARS (size_t);
16 char w_flg, s_flg;
17 char *s;
18 size_t n;
19 char t_flg;
20 static mbstate_t t = { 0 };
21 mbstate_t *pt;
22 wchar_t wc, *pwc, wc_ex;
24 TST_DO_TEST (mbrtowc)
26 TST_HEAD_LOCALE (mbrtowc, S_MBRTOWC);
27 TST_DO_REC (mbrtowc)
29 if (mbrtowc (NULL, "", 0, &t) != 0)
31 err_count++;
32 Result (C_FAILURE, S_MBRTOWC, CASE_3,
33 "Initialization failed - skipping this test case.");
34 continue;
37 TST_DO_SEQ (MBRTOWC_SEQNUM)
39 TST_GET_ERRET_SEQ (mbrtowc);
40 w_flg = TST_INPUT_SEQ (mbrtowc).w_flg;
41 s_flg = TST_INPUT_SEQ (mbrtowc).s_flg;
42 s = TST_INPUT_SEQ (mbrtowc).s;
43 n = TST_INPUT_SEQ (mbrtowc).n;
44 t_flg = TST_INPUT_SEQ (mbrtowc).t_flg;
45 pwc = (w_flg == 0) ? NULL : &wc;
47 if (s_flg == 0)
49 s = NULL;
52 if (n == USE_MBCURMAX)
54 n = MB_CUR_MAX;
57 pt = (t_flg == 0) ? NULL : &t;
59 TST_CLEAR_ERRNO;
60 ret = mbrtowc (pwc, s, n, pt);
61 TST_SAVE_ERRNO;
63 if (debug_flg)
65 fprintf (stdout, "mbrtowc() [ %s : %d : %d ] ret = %zd\n",
66 locale, rec + 1, seq_num + 1, ret);
67 fprintf (stdout, " errno = %hd\n",
68 errno_save);
71 TST_IF_RETURN (S_MBRTOWC)
75 if (pwc == NULL || s == NULL || ret == (size_t) - 1
76 || ret == (size_t) - 2)
78 continue;
81 wc_ex = TST_EXPECT_SEQ (mbrtowc).wc;
82 if (wc_ex == wc)
84 Result (C_SUCCESS, S_MBRTOWC, CASE_4, MS_PASSED);
86 else
88 err_count++;
89 Result (C_FAILURE, S_MBRTOWC, CASE_4,
90 "converted wc is different from an expected wc");
96 return err_count;