1 /* Test of u8_strmblen() function.
2 Copyright (C) 2010-2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */
30 /* Test NUL unit input. */
32 static const uint8_t input
[] = "";
33 ret
= u8_strmblen (input
);
37 /* Test ISO 646 unit input. */
42 for (c
= 1; c
< 0x80; c
++)
46 ret
= u8_strmblen (buf
);
51 /* Test 2-byte character input. */
53 static const uint8_t input
[] = { 0xC3, 0x97, 0 };
54 ret
= u8_strmblen (input
);
58 /* Test 3-byte character input. */
60 static const uint8_t input
[] = { 0xE2, 0x82, 0xAC, 0 };
61 ret
= u8_strmblen (input
);
65 /* Test 4-byte character input. */
67 static const uint8_t input
[] = { 0xF4, 0x8F, 0xBF, 0xBD, 0 };
68 ret
= u8_strmblen (input
);
72 /* Test incomplete/invalid 1-byte input. */
74 static const uint8_t input
[] = { 0xC1, 0 };
75 ret
= u8_strmblen (input
);
79 static const uint8_t input
[] = { 0xC3, 0 };
80 ret
= u8_strmblen (input
);
84 static const uint8_t input
[] = { 0xE2, 0 };
85 ret
= u8_strmblen (input
);
89 static const uint8_t input
[] = { 0xF4, 0 };
90 ret
= u8_strmblen (input
);
94 static const uint8_t input
[] = { 0xFE, 0 };
95 ret
= u8_strmblen (input
);
99 /* Test incomplete/invalid 2-byte input. */
101 static const uint8_t input
[] = { 0xE0, 0x9F, 0 };
102 ret
= u8_strmblen (input
);
106 static const uint8_t input
[] = { 0xE2, 0x82, 0 };
107 ret
= u8_strmblen (input
);
111 static const uint8_t input
[] = { 0xE2, 0xD0, 0 };
112 ret
= u8_strmblen (input
);
116 static const uint8_t input
[] = { 0xF0, 0x8F, 0 };
117 ret
= u8_strmblen (input
);
121 static const uint8_t input
[] = { 0xF3, 0x8F, 0 };
122 ret
= u8_strmblen (input
);
126 static const uint8_t input
[] = { 0xF3, 0xD0, 0 };
127 ret
= u8_strmblen (input
);
131 /* Test incomplete/invalid 3-byte input. */
133 static const uint8_t input
[] = { 0xF3, 0x8F, 0xBF, 0 };
134 ret
= u8_strmblen (input
);
138 static const uint8_t input
[] = { 0xF3, 0xD0, 0xBF, 0 };
139 ret
= u8_strmblen (input
);
143 static const uint8_t input
[] = { 0xF3, 0x8F, 0xD0, 0 };
144 ret
= u8_strmblen (input
);