[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / localization / locale.stdcvt / codecvt_utf16_in.pass.cpp
blob139a4b284625c17e9c98f81b981e0de3c1994c8c
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <codecvt>
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>
15 // {
16 // // unspecified
17 // };
19 // result
20 // in(stateT& state,
21 // const externT* from, const externT* from_end, const externT*& from_next,
22 // internT* to, internT* to_end, internT*& to_next) const;
24 #include <codecvt>
25 #include <cassert>
27 #include "test_macros.h"
29 int main(int, char**)
32 typedef std::codecvt_utf16<char32_t> C;
33 C c;
34 char32_t w = 0;
35 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
36 char32_t* wp = nullptr;
37 std::mbstate_t m;
38 const char* np = nullptr;
39 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
40 assert(r == std::codecvt_base::ok);
41 assert(wp == &w+1);
42 assert(np == n+4);
43 assert(w == 0x40003);
45 n[0] = char(0x10);
46 n[1] = char(0x05);
47 r = c.in(m, n, n+2, np, &w, &w+1, wp);
48 assert(r == std::codecvt_base::ok);
49 assert(wp == &w+1);
50 assert(np == n+2);
51 assert(w == 0x1005);
53 n[0] = char(0x04);
54 n[1] = char(0x53);
55 r = c.in(m, n, n+2, np, &w, &w+1, wp);
56 assert(r == std::codecvt_base::ok);
57 assert(wp == &w+1);
58 assert(np == n+2);
59 assert(w == 0x453);
61 w = 0x56;
62 n[0] = char(0x00);
63 n[1] = char(0x56);
64 r = c.in(m, n, n+2, np, &w, &w+1, wp);
65 assert(r == std::codecvt_base::ok);
66 assert(wp == &w+1);
67 assert(np == n+2);
68 assert(w == 0x56);
71 typedef std::codecvt_utf16<char32_t, 0x1000> C;
72 C c;
73 char32_t w = 0;
74 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
75 char32_t* wp = nullptr;
76 std::mbstate_t m;
77 const char* np = nullptr;
78 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
79 assert(r == std::codecvt_base::error);
80 assert(wp == &w);
81 assert(np == n);
82 assert(w == 0);
84 n[0] = char(0x10);
85 n[1] = char(0x05);
86 r = c.in(m, n, n+2, np, &w, &w+1, wp);
87 assert(r == std::codecvt_base::error);
88 assert(wp == &w);
89 assert(np == n);
90 assert(w == 0);
92 n[0] = char(0x04);
93 n[1] = char(0x53);
94 r = c.in(m, n, n+2, np, &w, &w+1, wp);
95 assert(r == std::codecvt_base::ok);
96 assert(wp == &w+1);
97 assert(np == n+2);
98 assert(w == 0x453);
100 w = 0x56;
101 n[0] = char(0x00);
102 n[1] = char(0x56);
103 r = c.in(m, n, n+2, np, &w, &w+1, wp);
104 assert(r == std::codecvt_base::ok);
105 assert(wp == &w+1);
106 assert(np == n+2);
107 assert(w == 0x56);
110 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
111 C c;
112 char32_t w = 0;
113 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
114 char32_t* wp = nullptr;
115 std::mbstate_t m;
116 const char* np = nullptr;
117 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
118 assert(r == std::codecvt_base::ok);
119 assert(wp == &w+1);
120 assert(np == n+6);
121 assert(w == 0x40003);
123 n[0] = char(0x10);
124 n[1] = char(0x05);
125 r = c.in(m, n, n+2, np, &w, &w+1, wp);
126 assert(r == std::codecvt_base::ok);
127 assert(wp == &w+1);
128 assert(np == n+2);
129 assert(w == 0x1005);
131 n[0] = char(0x04);
132 n[1] = char(0x53);
133 r = c.in(m, n, n+2, np, &w, &w+1, wp);
134 assert(r == std::codecvt_base::ok);
135 assert(wp == &w+1);
136 assert(np == n+2);
137 assert(w == 0x453);
139 w = 0x56;
140 n[0] = char(0x00);
141 n[1] = char(0x56);
142 r = c.in(m, n, n+2, np, &w, &w+1, wp);
143 assert(r == std::codecvt_base::ok);
144 assert(wp == &w+1);
145 assert(np == n+2);
146 assert(w == 0x56);
149 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
150 C c;
151 char32_t w = 0;
152 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
153 char32_t* wp = nullptr;
154 std::mbstate_t m;
155 const char* np = nullptr;
156 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
157 assert(r == std::codecvt_base::ok);
158 assert(wp == &w+1);
159 assert(np == n+4);
160 assert(w == 0x40003);
162 n[1] = char(0x10);
163 n[0] = char(0x05);
164 r = c.in(m, n, n+2, np, &w, &w+1, wp);
165 assert(r == std::codecvt_base::ok);
166 assert(wp == &w+1);
167 assert(np == n+2);
168 assert(w == 0x1005);
170 n[1] = char(0x04);
171 n[0] = char(0x53);
172 r = c.in(m, n, n+2, np, &w, &w+1, wp);
173 assert(r == std::codecvt_base::ok);
174 assert(wp == &w+1);
175 assert(np == n+2);
176 assert(w == 0x453);
178 w = 0x56;
179 n[1] = char(0x00);
180 n[0] = char(0x56);
181 r = c.in(m, n, n+2, np, &w, &w+1, wp);
182 assert(r == std::codecvt_base::ok);
183 assert(wp == &w+1);
184 assert(np == n+2);
185 assert(w == 0x56);
188 typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
189 C c;
190 char32_t w = 0;
191 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
192 char32_t* wp = nullptr;
193 std::mbstate_t m;
194 const char* np = nullptr;
195 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
196 assert(r == std::codecvt_base::error);
197 assert(wp == &w);
198 assert(np == n);
199 assert(w == 0);
201 n[1] = char(0x10);
202 n[0] = char(0x05);
203 r = c.in(m, n, n+2, np, &w, &w+1, wp);
204 assert(r == std::codecvt_base::error);
205 assert(wp == &w);
206 assert(np == n);
207 assert(w == 0);
209 n[1] = char(0x04);
210 n[0] = char(0x53);
211 r = c.in(m, n, n+2, np, &w, &w+1, wp);
212 assert(r == std::codecvt_base::ok);
213 assert(wp == &w+1);
214 assert(np == n+2);
215 assert(w == 0x453);
217 w = 0x56;
218 n[1] = char(0x00);
219 n[0] = char(0x56);
220 r = c.in(m, n, n+2, np, &w, &w+1, wp);
221 assert(r == std::codecvt_base::ok);
222 assert(wp == &w+1);
223 assert(np == n+2);
224 assert(w == 0x56);
227 typedef std::codecvt_utf16<char32_t, 0x10ffff,
228 std::codecvt_mode(std::consume_header | std::little_endian)> C;
230 C c;
231 char32_t w = 0;
232 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
233 char32_t* wp = nullptr;
234 std::mbstate_t m;
235 const char* np = nullptr;
236 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
237 assert(r == std::codecvt_base::ok);
238 assert(wp == &w+1);
239 assert(np == n+6);
240 assert(w == 0x40003);
242 n[1] = char(0x10);
243 n[0] = char(0x05);
244 r = c.in(m, n, n+2, np, &w, &w+1, wp);
245 assert(r == std::codecvt_base::ok);
246 assert(wp == &w+1);
247 assert(np == n+2);
248 assert(w == 0x1005);
250 n[1] = char(0x04);
251 n[0] = char(0x53);
252 r = c.in(m, n, n+2, np, &w, &w+1, wp);
253 assert(r == std::codecvt_base::ok);
254 assert(wp == &w+1);
255 assert(np == n+2);
256 assert(w == 0x453);
258 w = 0x56;
259 n[1] = char(0x00);
260 n[0] = char(0x56);
261 r = c.in(m, n, n+2, np, &w, &w+1, wp);
262 assert(r == std::codecvt_base::ok);
263 assert(wp == &w+1);
264 assert(np == n+2);
265 assert(w == 0x56);
268 typedef std::codecvt_utf16<char32_t> C;
269 C c;
270 char32_t w = 0;
271 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
272 char32_t* wp = nullptr;
273 std::mbstate_t m;
274 const char* np = nullptr;
275 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
276 assert(r == std::codecvt_base::ok);
277 assert(wp == &w+1);
278 assert(np == n+4);
279 assert(w == 0x40003);
281 n[0] = char(0x10);
282 n[1] = char(0x05);
283 r = c.in(m, n, n+2, np, &w, &w+1, wp);
284 assert(r == std::codecvt_base::ok);
285 assert(wp == &w+1);
286 assert(np == n+2);
287 assert(w == 0x1005);
289 n[0] = char(0x04);
290 n[1] = char(0x53);
291 r = c.in(m, n, n+2, np, &w, &w+1, wp);
292 assert(r == std::codecvt_base::ok);
293 assert(wp == &w+1);
294 assert(np == n+2);
295 assert(w == 0x453);
297 w = 0x56;
298 n[0] = char(0x00);
299 n[1] = char(0x56);
300 r = c.in(m, n, n+2, np, &w, &w+1, wp);
301 assert(r == std::codecvt_base::ok);
302 assert(wp == &w+1);
303 assert(np == n+2);
304 assert(w == 0x56);
307 typedef std::codecvt_utf16<char32_t, 0x1000> C;
308 C c;
309 char32_t w = 0;
310 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
311 char32_t* wp = nullptr;
312 std::mbstate_t m;
313 const char* np = nullptr;
314 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
315 assert(r == std::codecvt_base::error);
316 assert(wp == &w);
317 assert(np == n);
318 assert(w == 0);
320 n[0] = char(0x10);
321 n[1] = char(0x05);
322 r = c.in(m, n, n+2, np, &w, &w+1, wp);
323 assert(r == std::codecvt_base::error);
324 assert(wp == &w);
325 assert(np == n);
326 assert(w == 0);
328 n[0] = char(0x04);
329 n[1] = char(0x53);
330 r = c.in(m, n, n+2, np, &w, &w+1, wp);
331 assert(r == std::codecvt_base::ok);
332 assert(wp == &w+1);
333 assert(np == n+2);
334 assert(w == 0x453);
336 w = 0x56;
337 n[0] = char(0x00);
338 n[1] = char(0x56);
339 r = c.in(m, n, n+2, np, &w, &w+1, wp);
340 assert(r == std::codecvt_base::ok);
341 assert(wp == &w+1);
342 assert(np == n+2);
343 assert(w == 0x56);
346 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
347 C c;
348 char32_t w = 0;
349 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
350 char32_t* wp = nullptr;
351 std::mbstate_t m;
352 const char* np = nullptr;
353 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
354 assert(r == std::codecvt_base::ok);
355 assert(wp == &w+1);
356 assert(np == n+6);
357 assert(w == 0x40003);
359 n[0] = char(0x10);
360 n[1] = char(0x05);
361 r = c.in(m, n, n+2, np, &w, &w+1, wp);
362 assert(r == std::codecvt_base::ok);
363 assert(wp == &w+1);
364 assert(np == n+2);
365 assert(w == 0x1005);
367 n[0] = char(0x04);
368 n[1] = char(0x53);
369 r = c.in(m, n, n+2, np, &w, &w+1, wp);
370 assert(r == std::codecvt_base::ok);
371 assert(wp == &w+1);
372 assert(np == n+2);
373 assert(w == 0x453);
375 w = 0x56;
376 n[0] = char(0x00);
377 n[1] = char(0x56);
378 r = c.in(m, n, n+2, np, &w, &w+1, wp);
379 assert(r == std::codecvt_base::ok);
380 assert(wp == &w+1);
381 assert(np == n+2);
382 assert(w == 0x56);
385 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
386 C c;
387 char32_t w = 0;
388 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
389 char32_t* wp = nullptr;
390 std::mbstate_t m;
391 const char* np = nullptr;
392 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
393 assert(r == std::codecvt_base::ok);
394 assert(wp == &w+1);
395 assert(np == n+4);
396 assert(w == 0x40003);
398 n[1] = char(0x10);
399 n[0] = char(0x05);
400 r = c.in(m, n, n+2, np, &w, &w+1, wp);
401 assert(r == std::codecvt_base::ok);
402 assert(wp == &w+1);
403 assert(np == n+2);
404 assert(w == 0x1005);
406 n[1] = char(0x04);
407 n[0] = char(0x53);
408 r = c.in(m, n, n+2, np, &w, &w+1, wp);
409 assert(r == std::codecvt_base::ok);
410 assert(wp == &w+1);
411 assert(np == n+2);
412 assert(w == 0x453);
414 w = 0x56;
415 n[1] = char(0x00);
416 n[0] = char(0x56);
417 r = c.in(m, n, n+2, np, &w, &w+1, wp);
418 assert(r == std::codecvt_base::ok);
419 assert(wp == &w+1);
420 assert(np == n+2);
421 assert(w == 0x56);
424 typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
425 C c;
426 char32_t w = 0;
427 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
428 char32_t* wp = nullptr;
429 std::mbstate_t m;
430 const char* np = nullptr;
431 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
432 assert(r == std::codecvt_base::error);
433 assert(wp == &w);
434 assert(np == n);
435 assert(w == 0);
437 n[1] = char(0x10);
438 n[0] = char(0x05);
439 r = c.in(m, n, n+2, np, &w, &w+1, wp);
440 assert(r == std::codecvt_base::error);
441 assert(wp == &w);
442 assert(np == n);
443 assert(w == 0);
445 n[1] = char(0x04);
446 n[0] = char(0x53);
447 r = c.in(m, n, n+2, np, &w, &w+1, wp);
448 assert(r == std::codecvt_base::ok);
449 assert(wp == &w+1);
450 assert(np == n+2);
451 assert(w == 0x453);
453 w = 0x56;
454 n[1] = char(0x00);
455 n[0] = char(0x56);
456 r = c.in(m, n, n+2, np, &w, &w+1, wp);
457 assert(r == std::codecvt_base::ok);
458 assert(wp == &w+1);
459 assert(np == n+2);
460 assert(w == 0x56);
463 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
464 std::consume_header |
465 std::little_endian)> C;
466 C c;
467 char32_t w = 0;
468 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
469 char32_t* wp = nullptr;
470 std::mbstate_t m;
471 const char* np = nullptr;
472 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
473 assert(r == std::codecvt_base::ok);
474 assert(wp == &w+1);
475 assert(np == n+6);
476 assert(w == 0x40003);
478 n[1] = char(0x10);
479 n[0] = char(0x05);
480 r = c.in(m, n, n+2, np, &w, &w+1, wp);
481 assert(r == std::codecvt_base::ok);
482 assert(wp == &w+1);
483 assert(np == n+2);
484 assert(w == 0x1005);
486 n[1] = char(0x04);
487 n[0] = char(0x53);
488 r = c.in(m, n, n+2, np, &w, &w+1, wp);
489 assert(r == std::codecvt_base::ok);
490 assert(wp == &w+1);
491 assert(np == n+2);
492 assert(w == 0x453);
494 w = 0x56;
495 n[1] = char(0x00);
496 n[0] = char(0x56);
497 r = c.in(m, n, n+2, np, &w, &w+1, wp);
498 assert(r == std::codecvt_base::ok);
499 assert(wp == &w+1);
500 assert(np == n+2);
501 assert(w == 0x56);
505 typedef std::codecvt_utf16<char16_t> C;
506 C c;
507 char16_t w = 0;
508 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
509 char16_t* wp = nullptr;
510 std::mbstate_t m;
511 const char* np = nullptr;
512 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
513 assert(r == std::codecvt_base::error);
514 assert(wp == &w);
515 assert(np == n);
516 assert(w == 0);
518 n[0] = char(0x10);
519 n[1] = char(0x05);
520 r = c.in(m, n, n+2, np, &w, &w+1, wp);
521 assert(r == std::codecvt_base::ok);
522 assert(wp == &w+1);
523 assert(np == n+2);
524 assert(w == 0x1005);
526 n[0] = char(0x04);
527 n[1] = char(0x53);
528 r = c.in(m, n, n+2, np, &w, &w+1, wp);
529 assert(r == std::codecvt_base::ok);
530 assert(wp == &w+1);
531 assert(np == n+2);
532 assert(w == 0x453);
534 w = 0x56;
535 n[0] = char(0x00);
536 n[1] = char(0x56);
537 r = c.in(m, n, n+2, np, &w, &w+1, wp);
538 assert(r == std::codecvt_base::ok);
539 assert(wp == &w+1);
540 assert(np == n+2);
541 assert(w == 0x56);
544 typedef std::codecvt_utf16<char16_t, 0x1000> C;
545 C c;
546 char16_t w = 0;
547 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
548 char16_t* wp = nullptr;
549 std::mbstate_t m;
550 const char* np = nullptr;
551 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
552 assert(r == std::codecvt_base::error);
553 assert(wp == &w);
554 assert(np == n);
555 assert(w == 0);
557 n[0] = char(0x10);
558 n[1] = char(0x05);
559 r = c.in(m, n, n+2, np, &w, &w+1, wp);
560 assert(r == std::codecvt_base::error);
561 assert(wp == &w);
562 assert(np == n);
563 assert(w == 0);
565 n[0] = char(0x04);
566 n[1] = char(0x53);
567 r = c.in(m, n, n+2, np, &w, &w+1, wp);
568 assert(r == std::codecvt_base::ok);
569 assert(wp == &w+1);
570 assert(np == n+2);
571 assert(w == 0x453);
573 w = 0x56;
574 n[0] = char(0x00);
575 n[1] = char(0x56);
576 r = c.in(m, n, n+2, np, &w, &w+1, wp);
577 assert(r == std::codecvt_base::ok);
578 assert(wp == &w+1);
579 assert(np == n+2);
580 assert(w == 0x56);
583 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
584 C c;
585 char16_t w = 0;
586 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
587 char16_t* wp = nullptr;
588 std::mbstate_t m;
589 const char* np = nullptr;
590 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
591 assert(r == std::codecvt_base::error);
592 assert(wp == &w);
593 assert(np == n+2);
594 assert(w == 0);
596 n[0] = char(0x10);
597 n[1] = char(0x05);
598 r = c.in(m, n, n+2, np, &w, &w+1, wp);
599 assert(r == std::codecvt_base::ok);
600 assert(wp == &w+1);
601 assert(np == n+2);
602 assert(w == 0x1005);
604 n[0] = char(0x04);
605 n[1] = char(0x53);
606 r = c.in(m, n, n+2, np, &w, &w+1, wp);
607 assert(r == std::codecvt_base::ok);
608 assert(wp == &w+1);
609 assert(np == n+2);
610 assert(w == 0x453);
612 w = 0x56;
613 n[0] = char(0x00);
614 n[1] = char(0x56);
615 r = c.in(m, n, n+2, np, &w, &w+1, wp);
616 assert(r == std::codecvt_base::ok);
617 assert(wp == &w+1);
618 assert(np == n+2);
619 assert(w == 0x56);
622 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
623 C c;
624 char16_t w = 0;
625 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
626 char16_t* wp = nullptr;
627 std::mbstate_t m;
628 const char* np = nullptr;
629 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
630 assert(r == std::codecvt_base::error);
631 assert(wp == &w);
632 assert(np == n);
633 assert(w == 0);
635 n[1] = char(0x10);
636 n[0] = char(0x05);
637 r = c.in(m, n, n+2, np, &w, &w+1, wp);
638 assert(r == std::codecvt_base::ok);
639 assert(wp == &w+1);
640 assert(np == n+2);
641 assert(w == 0x1005);
643 n[1] = char(0x04);
644 n[0] = char(0x53);
645 r = c.in(m, n, n+2, np, &w, &w+1, wp);
646 assert(r == std::codecvt_base::ok);
647 assert(wp == &w+1);
648 assert(np == n+2);
649 assert(w == 0x453);
651 w = 0x56;
652 n[1] = char(0x00);
653 n[0] = char(0x56);
654 r = c.in(m, n, n+2, np, &w, &w+1, wp);
655 assert(r == std::codecvt_base::ok);
656 assert(wp == &w+1);
657 assert(np == n+2);
658 assert(w == 0x56);
661 typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
662 C c;
663 char16_t w = 0;
664 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
665 char16_t* wp = nullptr;
666 std::mbstate_t m;
667 const char* np = nullptr;
668 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
669 assert(r == std::codecvt_base::error);
670 assert(wp == &w);
671 assert(np == n);
672 assert(w == 0);
674 n[1] = char(0x10);
675 n[0] = char(0x05);
676 r = c.in(m, n, n+2, np, &w, &w+1, wp);
677 assert(r == std::codecvt_base::error);
678 assert(wp == &w);
679 assert(np == n);
680 assert(w == 0);
682 n[1] = char(0x04);
683 n[0] = char(0x53);
684 r = c.in(m, n, n+2, np, &w, &w+1, wp);
685 assert(r == std::codecvt_base::ok);
686 assert(wp == &w+1);
687 assert(np == n+2);
688 assert(w == 0x453);
690 w = 0x56;
691 n[1] = char(0x00);
692 n[0] = char(0x56);
693 r = c.in(m, n, n+2, np, &w, &w+1, wp);
694 assert(r == std::codecvt_base::ok);
695 assert(wp == &w+1);
696 assert(np == n+2);
697 assert(w == 0x56);
700 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
701 std::consume_header |
702 std::little_endian)> C;
703 C c;
704 char16_t w = 0;
705 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
706 char16_t* wp = nullptr;
707 std::mbstate_t m;
708 const char* np = nullptr;
709 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
710 assert(r == std::codecvt_base::error);
711 assert(wp == &w);
712 assert(np == n+2);
713 assert(w == 0);
715 n[1] = char(0x10);
716 n[0] = char(0x05);
717 r = c.in(m, n, n+2, np, &w, &w+1, wp);
718 assert(r == std::codecvt_base::ok);
719 assert(wp == &w+1);
720 assert(np == n+2);
721 assert(w == 0x1005);
723 n[1] = char(0x04);
724 n[0] = char(0x53);
725 r = c.in(m, n, n+2, np, &w, &w+1, wp);
726 assert(r == std::codecvt_base::ok);
727 assert(wp == &w+1);
728 assert(np == n+2);
729 assert(w == 0x453);
731 w = 0x56;
732 n[1] = char(0x00);
733 n[0] = char(0x56);
734 r = c.in(m, n, n+2, np, &w, &w+1, wp);
735 assert(r == std::codecvt_base::ok);
736 assert(wp == &w+1);
737 assert(np == n+2);
738 assert(w == 0x56);
741 return 0;