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>
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
<wchar_t> C
;
32 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
34 int r
= c
.length(m
, n
, n
+4, 1);
40 r
= c
.length(m
, n
, n
+3, 2);
45 r
= c
.length(m
, n
, n
+2, 3);
49 r
= c
.length(m
, n
, n
+1, 3);
53 typedef std::codecvt_utf8
<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, 1);
63 r
= c
.length(m
, n
, n
+3, 2);
68 r
= c
.length(m
, n
, n
+2, 3);
72 r
= c
.length(m
, n
, n
+1, 3);
76 typedef std::codecvt_utf8
<wchar_t, 0xFFFFFFFF, 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, 1);
86 r
= c
.length(m
, n
, n
+3, 2);
94 r
= c
.length(m
, n
, n
+5, 3);
98 r
= c
.length(m
, n
, n
+1, 3);
102 typedef std::codecvt_utf8
<char32_t
> C
;
104 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
106 int r
= c
.length(m
, n
, n
+4, 1);
112 r
= c
.length(m
, n
, n
+3, 2);
117 r
= c
.length(m
, n
, n
+2, 3);
121 r
= c
.length(m
, n
, n
+1, 3);
125 typedef std::codecvt_utf8
<char32_t
, 0x1000> C
;
127 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
129 int r
= c
.length(m
, n
, n
+4, 1);
135 r
= c
.length(m
, n
, n
+3, 2);
140 r
= c
.length(m
, n
, n
+2, 3);
144 r
= c
.length(m
, n
, n
+1, 3);
148 typedef std::codecvt_utf8
<char32_t
, 0xFFFFFFFF, std::consume_header
> C
;
150 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
152 int r
= c
.length(m
, n
, n
+7, 1);
158 r
= c
.length(m
, n
, n
+3, 2);
166 r
= c
.length(m
, n
, n
+5, 3);
170 r
= c
.length(m
, n
, n
+1, 3);
174 typedef std::codecvt_utf8
<char16_t
> C
;
176 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
178 int r
= c
.length(m
, n
, n
+4, 1);
184 r
= c
.length(m
, n
, n
+3, 2);
189 r
= c
.length(m
, n
, n
+2, 3);
193 r
= c
.length(m
, n
, n
+1, 3);
197 typedef std::codecvt_utf8
<char16_t
, 0x1000> C
;
199 char n
[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
201 int r
= c
.length(m
, n
, n
+4, 1);
207 r
= c
.length(m
, n
, n
+3, 2);
212 r
= c
.length(m
, n
, n
+2, 3);
216 r
= c
.length(m
, n
, n
+1, 3);
220 typedef std::codecvt_utf8
<char16_t
, 0xFFFFFFFF, std::consume_header
> C
;
222 char n
[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
224 int r
= c
.length(m
, n
, n
+7, 1);
230 r
= c
.length(m
, n
, n
+3, 2);
238 r
= c
.length(m
, n
, n
+5, 3);
242 r
= c
.length(m
, n
, n
+1, 3);