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_utf8_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_utf8_utf16
<wchar_t> C
;
32 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
34 int r
= c
.length(m
, n
, n
+4, 2);
40 r
= c
.length(m
, n
, n
+3, 2);
45 r
= c
.length(m
, n
, n
+2, 2);
49 r
= c
.length(m
, n
, n
+1, 2);
53 typedef std::codecvt_utf8_utf16
<wchar_t, 0x1000> C
;
55 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
57 int r
= c
.length(m
, n
, n
+4, 2);
63 r
= c
.length(m
, n
, n
+3, 2);
68 r
= c
.length(m
, n
, n
+2, 2);
72 r
= c
.length(m
, n
, n
+1, 2);
76 typedef std::codecvt_utf8_utf16
<wchar_t, 0x10ffff, std::consume_header
> C
;
78 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
80 int r
= c
.length(m
, n
, n
+7, 2);
86 r
= c
.length(m
, n
, n
+3, 2);
91 r
= c
.length(m
, n
, n
+2, 2);
95 r
= c
.length(m
, n
, n
+1, 2);
99 typedef std::codecvt_utf8_utf16
<char32_t
> C
;
101 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
103 int r
= c
.length(m
, n
, n
+4, 2);
109 r
= c
.length(m
, n
, n
+3, 2);
114 r
= c
.length(m
, n
, n
+2, 2);
118 r
= c
.length(m
, n
, n
+1, 2);
122 typedef std::codecvt_utf8_utf16
<char32_t
, 0x1000> C
;
124 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
126 int r
= c
.length(m
, n
, n
+4, 2);
132 r
= c
.length(m
, n
, n
+3, 2);
137 r
= c
.length(m
, n
, n
+2, 2);
141 r
= c
.length(m
, n
, n
+1, 2);
145 typedef std::codecvt_utf8_utf16
<char32_t
, 0x10ffff, std::consume_header
> C
;
147 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
149 int r
= c
.length(m
, n
, n
+7, 2);
155 r
= c
.length(m
, n
, n
+3, 2);
160 r
= c
.length(m
, n
, n
+2, 2);
164 r
= c
.length(m
, n
, n
+1, 2);
168 typedef std::codecvt_utf8_utf16
<char16_t
> C
;
170 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
172 int r
= c
.length(m
, n
, n
+4, 2);
178 r
= c
.length(m
, n
, n
+3, 2);
183 r
= c
.length(m
, n
, n
+2, 2);
187 r
= c
.length(m
, n
, n
+1, 2);
191 typedef std::codecvt_utf8_utf16
<char16_t
, 0x1000> C
;
193 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
195 int r
= c
.length(m
, n
, n
+4, 2);
201 r
= c
.length(m
, n
, n
+3, 2);
206 r
= c
.length(m
, n
, n
+2, 2);
210 r
= c
.length(m
, n
, n
+1, 2);
214 typedef std::codecvt_utf8_utf16
<char16_t
, 0x10ffff, std::consume_header
> C
;
216 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
218 int r
= c
.length(m
, n
, n
+7, 2);
224 r
= c
.length(m
, n
, n
+3, 2);
229 r
= c
.length(m
, n
, n
+2, 2);
233 r
= c
.length(m
, n
, n
+1, 2);