* misc/sys/queue.h: Remove uses of all QUEUEDEBUG_* macros.
[glibc.git] / localedata / tests-mbwc / tst_mblen.c
blob35ccf6c1a6e5e4b9424226857aef5d4ee34c75e1
1 /*
2 MBLEN: int mblen (char *s, size_t n)
3 */
5 #define TST_FUNCTION mblen
7 #include "tsp_common.c"
8 #include "dat_mblen.c"
10 int
11 tst_mblen (FILE * fp, int debug_flg)
13 TST_DECL_VARS (int);
14 char s_flg;
15 const char *s_in;
16 size_t n;
18 TST_DO_TEST (mblen)
20 TST_HEAD_LOCALE (mblen, S_MBLEN);
21 TST_DO_REC (mblen)
23 TST_GET_ERRET (mblen);
24 s_flg = TST_INPUT (mblen).s_flg;
25 s_in = TST_INPUT (mblen).s;
26 n = TST_INPUT (mblen).n;
28 if (s_flg == 0)
30 s_in = NULL;
33 if (n == USE_MBCURMAX)
35 n = MB_CUR_MAX;
38 TST_CLEAR_ERRNO;
39 ret = mblen (s_in, n);
40 TST_SAVE_ERRNO;
42 TST_IF_RETURN (S_MBLEN)
44 if (s_in == NULL)
45 { /* state dependency */
46 if (ret_exp == +1)
47 { /* state-dependent */
48 if (ret != 0)
50 /* non-zero: state-dependent encoding */
51 Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
53 else
55 err_count++;
56 Result (C_FAILURE, S_MBLEN, CASE_3,
57 "should be state-dependent encoding, "
58 "but the return value shows it is"
59 " state-independent");
63 if (ret_exp == 0)
64 { /* state-independent */
65 if (ret == 0)
67 /* non-zero: state-dependent encoding */
68 Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
70 else
72 err_count++;
73 Result (C_FAILURE, S_MBLEN, CASE_3,
74 "should be state-independent encoding, "
75 "but the return value shows it is"
76 " state-dependent");
84 return err_count;