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 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT
13 // template <class Elem, unsigned long Maxcode = 0x10ffff,
14 // codecvt_mode Mode = (codecvt_mode)0>
15 // class codecvt_utf8_utf16
16 // : public codecvt<Elem, char, mbstate_t>
21 // int length(stateT& state, const externT* from, const externT* from_end,
27 #include "test_macros.h"
31 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
33 typedef std::codecvt_utf8_utf16
<wchar_t> C
;
35 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
37 int r
= c
.length(m
, n
, n
+4, 2);
43 r
= c
.length(m
, n
, n
+3, 2);
48 r
= c
.length(m
, n
, n
+2, 2);
52 r
= c
.length(m
, n
, n
+1, 2);
56 typedef std::codecvt_utf8_utf16
<wchar_t, 0x1000> C
;
58 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
60 int r
= c
.length(m
, n
, n
+4, 2);
66 r
= c
.length(m
, n
, n
+3, 2);
71 r
= c
.length(m
, n
, n
+2, 2);
75 r
= c
.length(m
, n
, n
+1, 2);
79 typedef std::codecvt_utf8_utf16
<wchar_t, 0x10ffff, std::consume_header
> C
;
81 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
83 int r
= c
.length(m
, n
, n
+7, 2);
89 r
= c
.length(m
, n
, n
+3, 2);
94 r
= c
.length(m
, n
, n
+2, 2);
98 r
= c
.length(m
, n
, n
+1, 2);
101 #endif // TEST_HAS_NO_WIDE_CHARACTERS
103 typedef std::codecvt_utf8_utf16
<char32_t
> C
;
105 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
107 int r
= c
.length(m
, n
, n
+4, 2);
113 r
= c
.length(m
, n
, n
+3, 2);
118 r
= c
.length(m
, n
, n
+2, 2);
122 r
= c
.length(m
, n
, n
+1, 2);
126 typedef std::codecvt_utf8_utf16
<char32_t
, 0x1000> C
;
128 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
130 int r
= c
.length(m
, n
, n
+4, 2);
136 r
= c
.length(m
, n
, n
+3, 2);
141 r
= c
.length(m
, n
, n
+2, 2);
145 r
= c
.length(m
, n
, n
+1, 2);
149 typedef std::codecvt_utf8_utf16
<char32_t
, 0x10ffff, std::consume_header
> C
;
151 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
153 int r
= c
.length(m
, n
, n
+7, 2);
159 r
= c
.length(m
, n
, n
+3, 2);
164 r
= c
.length(m
, n
, n
+2, 2);
168 r
= c
.length(m
, n
, n
+1, 2);
172 typedef std::codecvt_utf8_utf16
<char16_t
> C
;
174 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
176 int r
= c
.length(m
, n
, n
+4, 2);
182 r
= c
.length(m
, n
, n
+3, 2);
187 r
= c
.length(m
, n
, n
+2, 2);
191 r
= c
.length(m
, n
, n
+1, 2);
195 typedef std::codecvt_utf8_utf16
<char16_t
, 0x1000> C
;
197 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
199 int r
= c
.length(m
, n
, n
+4, 2);
205 r
= c
.length(m
, n
, n
+3, 2);
210 r
= c
.length(m
, n
, n
+2, 2);
214 r
= c
.length(m
, n
, n
+1, 2);
218 typedef std::codecvt_utf8_utf16
<char16_t
, 0x10ffff, std::consume_header
> C
;
220 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
222 int r
= c
.length(m
, n
, n
+7, 2);
228 r
= c
.length(m
, n
, n
+3, 2);
233 r
= c
.length(m
, n
, n
+2, 2);
237 r
= c
.length(m
, n
, n
+1, 2);