1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template <class Elem, unsigned long Maxcode = 0x10ffff,
12 // codecvt_mode Mode = (codecvt_mode)0>
13 // class codecvt_utf16
14 // : public codecvt<Elem, char, mbstate_t>
19 // int length(stateT& state, const externT* from, const externT* from_end,
25 #include "test_macros.h"
30 typedef std::codecvt_utf16
<wchar_t> C
;
32 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
34 int r
= c
.length(m
, n
, n
+4, 2);
39 r
= c
.length(m
, n
, n
+2, 2);
44 r
= c
.length(m
, n
, n
+2, 2);
49 r
= c
.length(m
, n
, n
+2, 2);
53 typedef std::codecvt_utf16
<wchar_t, 0x1000> C
;
55 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
57 int r
= c
.length(m
, n
, n
+4, 2);
62 r
= c
.length(m
, n
, n
+2, 2);
67 r
= c
.length(m
, n
, n
+2, 2);
72 r
= c
.length(m
, n
, n
+2, 2);
76 typedef std::codecvt_utf16
<wchar_t, 0x10ffff, std::consume_header
> C
;
78 char n
[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
80 int r
= c
.length(m
, n
, n
+6, 2);
85 r
= c
.length(m
, n
, n
+2, 2);
90 r
= c
.length(m
, n
, n
+2, 2);
95 r
= c
.length(m
, n
, n
+2, 2);
99 typedef std::codecvt_utf16
<wchar_t, 0x10ffff, std::little_endian
> C
;
101 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
103 int r
= c
.length(m
, n
, n
+4, 2);
108 r
= c
.length(m
, n
, n
+2, 2);
113 r
= c
.length(m
, n
, n
+2, 2);
118 r
= c
.length(m
, n
, n
+2, 2);
122 typedef std::codecvt_utf16
<wchar_t, 0x1000, std::little_endian
> C
;
124 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
126 int r
= c
.length(m
, n
, n
+4, 2);
131 r
= c
.length(m
, n
, n
+2, 2);
136 r
= c
.length(m
, n
, n
+2, 2);
141 r
= c
.length(m
, n
, n
+2, 2);
145 typedef std::codecvt_utf16
<wchar_t, 0x10ffff, std::codecvt_mode(
146 std::consume_header
|
147 std::little_endian
)> C
;
149 char n
[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
151 int r
= c
.length(m
, n
, n
+6, 2);
156 r
= c
.length(m
, n
, n
+2, 2);
161 r
= c
.length(m
, n
, n
+2, 2);
166 r
= c
.length(m
, n
, n
+2, 2);
170 typedef std::codecvt_utf16
<char32_t
> C
;
172 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
174 int r
= c
.length(m
, n
, n
+4, 2);
179 r
= c
.length(m
, n
, n
+2, 2);
184 r
= c
.length(m
, n
, n
+2, 2);
189 r
= c
.length(m
, n
, n
+2, 2);
193 typedef std::codecvt_utf16
<char32_t
, 0x1000> C
;
195 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
197 int r
= c
.length(m
, n
, n
+4, 2);
202 r
= c
.length(m
, n
, n
+2, 2);
207 r
= c
.length(m
, n
, n
+2, 2);
212 r
= c
.length(m
, n
, n
+2, 2);
216 typedef std::codecvt_utf16
<char32_t
, 0x10ffff, std::consume_header
> C
;
218 char n
[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
220 int r
= c
.length(m
, n
, n
+6, 2);
225 r
= c
.length(m
, n
, n
+2, 2);
230 r
= c
.length(m
, n
, n
+2, 2);
235 r
= c
.length(m
, n
, n
+2, 2);
239 typedef std::codecvt_utf16
<char32_t
, 0x10ffff, std::little_endian
> C
;
241 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
243 int r
= c
.length(m
, n
, n
+4, 2);
248 r
= c
.length(m
, n
, n
+2, 2);
253 r
= c
.length(m
, n
, n
+2, 2);
258 r
= c
.length(m
, n
, n
+2, 2);
262 typedef std::codecvt_utf16
<char32_t
, 0x1000, std::little_endian
> C
;
264 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
266 int r
= c
.length(m
, n
, n
+4, 2);
271 r
= c
.length(m
, n
, n
+2, 2);
276 r
= c
.length(m
, n
, n
+2, 2);
281 r
= c
.length(m
, n
, n
+2, 2);
285 typedef std::codecvt_utf16
<char32_t
, 0x10ffff, std::codecvt_mode(
286 std::consume_header
|
287 std::little_endian
)> C
;
289 char n
[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
291 int r
= c
.length(m
, n
, n
+6, 2);
296 r
= c
.length(m
, n
, n
+2, 2);
301 r
= c
.length(m
, n
, n
+2, 2);
306 r
= c
.length(m
, n
, n
+2, 2);
311 typedef std::codecvt_utf16
<char16_t
> C
;
313 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
315 int r
= c
.length(m
, n
, n
+4, 2);
320 r
= c
.length(m
, n
, n
+2, 2);
325 r
= c
.length(m
, n
, n
+2, 2);
330 r
= c
.length(m
, n
, n
+2, 2);
334 typedef std::codecvt_utf16
<char16_t
, 0x1000> C
;
336 char n
[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
338 int r
= c
.length(m
, n
, n
+4, 2);
343 r
= c
.length(m
, n
, n
+2, 2);
348 r
= c
.length(m
, n
, n
+2, 2);
353 r
= c
.length(m
, n
, n
+2, 2);
357 typedef std::codecvt_utf16
<char16_t
, 0x10ffff, std::consume_header
> C
;
359 char n
[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
361 int r
= c
.length(m
, n
, n
+6, 2);
366 r
= c
.length(m
, n
, n
+2, 2);
371 r
= c
.length(m
, n
, n
+2, 2);
376 r
= c
.length(m
, n
, n
+2, 2);
380 typedef std::codecvt_utf16
<char16_t
, 0x10ffff, std::little_endian
> C
;
382 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
384 int r
= c
.length(m
, n
, n
+4, 2);
389 r
= c
.length(m
, n
, n
+2, 2);
394 r
= c
.length(m
, n
, n
+2, 2);
399 r
= c
.length(m
, n
, n
+2, 2);
403 typedef std::codecvt_utf16
<char16_t
, 0x1000, std::little_endian
> C
;
405 char n
[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
407 int r
= c
.length(m
, n
, n
+4, 2);
412 r
= c
.length(m
, n
, n
+2, 2);
417 r
= c
.length(m
, n
, n
+2, 2);
422 r
= c
.length(m
, n
, n
+2, 2);
426 typedef std::codecvt_utf16
<char16_t
, 0x10ffff, std::codecvt_mode(
427 std::consume_header
|
428 std::little_endian
)> C
;
430 char n
[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
432 int r
= c
.length(m
, n
, n
+6, 2);
437 r
= c
.length(m
, n
, n
+2, 2);
442 r
= c
.length(m
, n
, n
+2, 2);
447 r
= c
.length(m
, n
, n
+2, 2);