1 /* Test of u16_check() function.
2 Copyright (C) 2010-2017 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. */
28 /* Test empty string. */
30 static const uint16_t input
[] = { 0 };
31 ASSERT (u16_check (input
, 0) == NULL
);
34 /* Test valid non-empty string. */
36 static const uint16_t input
[] = /* "Данило Шеган" */
37 { 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, 0x0020, 0x0428, 0x0435, 0x0433, 0x0430, 0x043D };
38 ASSERT (u16_check (input
, SIZEOF (input
)) == NULL
);
41 /* Test out-of-range character with 2 units: U+110000. */
43 static const uint16_t input
[] = { 0x0414, 0x0430, 0xDBFF, 0xE000 };
44 ASSERT (u16_check (input
, SIZEOF (input
)) == input
+ 2);
47 /* Test surrogate codepoints. */
49 static const uint16_t input
[] = { 0x0414, 0x0430, 0xDBFF, 0xDFFF };
50 ASSERT (u16_check (input
, SIZEOF (input
)) == NULL
);
53 static const uint16_t input
[] = { 0x0414, 0x0430, 0xDBFF };
54 ASSERT (u16_check (input
, SIZEOF (input
)) == input
+ 2);
57 static const uint16_t input
[] = { 0x0414, 0x0430, 0xDFFF };
58 ASSERT (u16_check (input
, SIZEOF (input
)) == input
+ 2);
61 static const uint16_t input
[] = { 0x0414, 0x0430, 0xDFFF, 0xDBFF };
62 ASSERT (u16_check (input
, SIZEOF (input
)) == input
+ 2);