Update x86_64 multiarch functions for <cpu-features.h>
[glibc.git] / localedata / tests-mbwc / tst_wcrtomb.c
blob0029a494051ca440e3ab97ecc5741e8c0297758a
1 /*
2 WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
3 */
5 #define TST_FUNCTION wcrtomb
7 #include "tsp_common.c"
8 #include "dat_wcrtomb.c"
11 int
12 tst_wcrtomb (FILE * fp, int debug_flg)
14 TST_DECL_VARS (wchar_t);
15 wchar_t wc;
16 char s[MBSSIZE], *s_in, *s_ex;
17 char t_flg, t_ini;
18 static mbstate_t t = { 0 };
19 mbstate_t *pt;
20 int err, i;
22 TST_DO_TEST (wcrtomb)
24 TST_HEAD_LOCALE (wcrtomb, S_WCRTOMB);
25 TST_DO_REC (wcrtomb)
27 TST_GET_ERRET (wcrtomb);
28 s_in = ((TST_INPUT (wcrtomb).s_flg) == 0) ? (char *) NULL : s;
29 wc = TST_INPUT (wcrtomb).wc;
30 t_flg = TST_INPUT (wcrtomb).t_flg;
31 t_ini = TST_INPUT (wcrtomb).t_init;
32 pt = (t_flg == 0) ? NULL : &t;
34 if (t_ini != 0)
36 memset (&t, 0, sizeof (t));
39 TST_CLEAR_ERRNO;
40 ret = wcrtomb (s_in, wc, pt);
41 TST_SAVE_ERRNO;
43 if (debug_flg)
45 fprintf (stdout, "wcrtomb() [ %s : %d ] ret = %lu\n", locale,
46 rec + 1, (unsigned long int) ret);
47 fprintf (stdout, " errno = %d\n", errno_save);
50 TST_IF_RETURN (S_WCRTOMB)
54 s_ex = TST_EXPECT (wcrtomb).s;
56 if (s_in)
58 for (i = 0, err = 0; *(s_ex + i) != 0 && i < MBSSIZE; i++)
60 if (s_in[i] != s_ex[i])
62 err++;
63 err_count++;
64 Result (C_FAILURE, S_WCRTOMB, CASE_4,
65 "copied string is different from an "
66 "expected string");
67 break;
70 if (!err)
72 Result (C_SUCCESS, S_WCRTOMB, CASE_4, MS_PASSED);
78 return err_count;