Update.
[glibc.git] / localedata / tests-mbwc / tst_strfmon.c
blob88e93167df439c1fe1b7297a7385c31f67ffd8f5
1 /*
2 STRFMON: size_t strfmon (char *buf, size_t nbyte, const char *fmt, ...)
3 */
5 #define TST_FUNCTION strfmon
7 #include "tsp_common.c"
8 #include "dat_strfmon.c"
9 #include <monetary.h>
11 int
12 tst_strfmon (FILE * fp, int debug_flg)
14 TST_DECL_VARS (size_t);
15 char buf[MONSIZE], *mon;
16 size_t nbt;
17 char *fmt;
18 double val;
20 TST_DO_TEST (strfmon)
22 TST_HEAD_LOCALE (strfmon, S_STRFMON);
23 TST_DO_REC (strfmon)
25 TST_GET_ERRET (strfmon);
26 nbt = TST_INPUT (strfmon).nbytes;
27 fmt = TST_INPUT (strfmon).fmt;
28 val = TST_INPUT (strfmon).val;
29 memset (buf, 0, MONSIZE);
30 if (nbt > MONSIZE)
32 err_count++;
33 Result (C_FAILURE, S_STRFMON, CASE_3, "buffer too small in test");
34 continue;
37 TST_CLEAR_ERRNO;
38 ret = strfmon (buf, nbt, fmt, val, val, val);
39 TST_SAVE_ERRNO;
41 if (debug_flg) /* seems fprintf doesn't update the errno */
43 fprintf (stdout, "strfmon() [ %s : %d ]\n", locale, rec + 1);
44 fprintf (stdout, " : err = %d | %s\n", errno_save,
45 strerror (errno));
46 fprintf (stdout, " : ret = %zd; \t fmt = |%s|\n", ret, fmt);
47 fprintf (stdout, " : buf = |%s|\n\n", buf);
50 TST_IF_RETURN (S_STRFMON)
53 if (errno != 0 || ret == -1)
55 continue;
58 mon = TST_EXPECT (strfmon).mon;
60 if (!strcmp (buf, mon))
62 Result (C_SUCCESS, S_STRFMON, CASE_3, MS_PASSED);
64 else
66 err_count++;
67 Result (C_FAILURE, S_STRFMON, CASE_3, "the formatted string is "
68 "different from an expected result");
73 return err_count;