2.9
[glibc/nacl-glibc.git] / localedata / tests-mbwc / dat_mblen.c
blob507ab8f35c61ba1fb42ab2c897e5d608d0d228da
1 /*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
4 * FILE: dat_mblen.c
6 * MBLEN: int mblen (char *s, size_t n);
7 */
11 * NOTE:
12 * int mblen (char *s, size_t n);
14 * where n: a maximum number of bytes
16 * return - the number of bytes
18 * CAUTION:
20 * o When you feed a null pointer for a string (s) to the function,
21 * set s_flg=0 instead of putting just a 'NULL' there.
22 * Even if you set a 'NULL', it doens't mean a NULL pointer.
24 * o When s is a null pointer, the function checks state dependency.
26 * state-dependent encoding - return NON-zero
27 * state-independent encoding - return 0
29 * If state-dependent encoding is expected, set
31 * s_flg = 0, ret_flg = 0, ret_val = +1
33 * If state-independent encoding is expected, set
35 * s_flg = 0, ret_flg = 0, ret_val = 0
38 * When you set ret_flg=1, the test program simply compares an
39 * actual return value with an expected value. You can check
40 * state-independent case (return value is 0) in that way, but
41 * you can not check state-dependent case. So when you check
42 * state- dependency in this test function: tst_mblen(), set
43 * ret_flg=0 always. It's a special case, and the test
44 * function takes care of it.
46 * s_flg=0 ret_flg=0
47 * | |
48 * { 0, 0 }, { 0, 0, 0, x }
49 * | |
50 * not used ret_val: 0/+1
51 * (expected val) */
54 TST_MBLEN tst_mblen_loc [] = {
56 { Tmblen, TST_LOC_de },
58 /* 01: a character. */
59 { { 1, "\300", USE_MBCURMAX }, { 0, 1, 1 } },
60 /* 02: a character. */
61 { { 1, "\309", USE_MBCURMAX }, { 0, 1, 1 } },
62 /* 03: a character + an invalid byte. */
63 { { 1, "Z\204", USE_MBCURMAX }, { 0, 1, +1 } },
64 /* 04: control/invalid characters. */
65 { { 1, "\177\000", USE_MBCURMAX }, { 0, 1, +1 } },
66 /* 05: a null string. */
67 { { 1, "", USE_MBCURMAX }, { 0, 1, 0 } },
68 /* 06: a null pointer. */
69 { { 0, "", USE_MBCURMAX }, { 0, 0, 0 } },
70 /* Last element. */
71 { .is_last = 1 }
75 { Tmblen, TST_LOC_enUS },
77 /* 01: a character. */
78 { { 1, "A", USE_MBCURMAX }, { 0, 1, 1 } },
79 /* 02: a character. */
80 { { 1, "a", USE_MBCURMAX }, { 0, 1, 1 } },
81 /* 03: a character + an invalid byte. */
82 { { 1, "Z\204", USE_MBCURMAX }, { 0, 1, +1 } },
83 /* 04: control/invalid characters. */
84 { { 1, "\177\000", USE_MBCURMAX }, { 0, 1, +1 } },
85 /* 05: a null string. */
86 { { 1, "", USE_MBCURMAX }, { 0, 1, 0 } },
87 /* 06: a null pointer. */
88 { { 0, "", USE_MBCURMAX }, { 0, 0, 0 } },
89 /* Last element. */
90 { .is_last = 1 }
94 { Tmblen, TST_LOC_eucJP },
96 /* 01: a character. */
97 { { 1, "\264\301", USE_MBCURMAX }, { 0, 1, 2 } },
98 /* 02: a character. */
99 { { 1, "\216\261", USE_MBCURMAX }, { 0, 1, 2 } },
100 /* 03: a character + an invalid byte. */
101 { { 1, "\260\241\200", USE_MBCURMAX }, { 0, 1, 2 } },
102 /* 04: control/invalid characters. */
103 { { 1, "\377\202", USE_MBCURMAX }, { EILSEQ, 1, -1 } },
104 /* 05: a null string. */
105 { { 1, "", USE_MBCURMAX }, { 0, 1, 0 } },
106 /* 06: a null pointer. */
107 { { 0, "", USE_MBCURMAX }, { 0, 0, 0 } },
108 /* Last element. */
109 { .is_last = 1 }
113 { Tmblen, TST_LOC_end}