1 | /* |
2 | * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY |
3 | * |
4 | * FILE: dat_mblen.c |
5 | * |
6 | * MBLEN: int mblen (char *s, size_t n); |
7 | */ |
8 | |
9 | |
10 | /* |
11 | * NOTE: |
12 | * int mblen (char *s, size_t n); |
13 | * |
14 | * where n: a maximum number of bytes |
15 | * |
16 | * return - the number of bytes |
17 | * |
18 | * CAUTION: |
19 | * |
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. |
23 | * |
24 | * o When s is a null pointer, the function checks state dependency. |
25 | * |
26 | * state-dependent encoding - return NON-zero |
27 | * state-independent encoding - return 0 |
28 | * |
29 | * If state-dependent encoding is expected, set |
30 | * |
31 | * s_flg = 0, ret_flg = 0, ret_val = +1 |
32 | * |
33 | * If state-independent encoding is expected, set |
34 | * |
35 | * s_flg = 0, ret_flg = 0, ret_val = 0 |
36 | * |
37 | * |
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. |
45 | * |
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) */ |
52 | |
53 | |
54 | TST_MBLEN tst_mblen_loc [] = { |
55 | { |
56 | { Tmblen, TST_LOC_de }, |
57 | { |
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 } |
72 | } |
73 | }, |
74 | { |
75 | { Tmblen, TST_LOC_enUS }, |
76 | { |
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 } |
91 | } |
92 | }, |
93 | { |
94 | { Tmblen, TST_LOC_eucJP }, |
95 | { |
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 } |
110 | } |
111 | }, |
112 | { |
113 | { Tmblen, TST_LOC_end} |
114 | } |
115 | }; |
116 | |