[NFC][Py Reformat] Reformat python files in libcxx/libcxxabi
[llvm-project.git] / libcxx / test / std / localization / locale.stdcvt / codecvt_utf16_in.pass.cpp
blob8d4f48e8f54ddcff9ad0053ac0b1c6e53c290dc8
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 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
13 // template <class Elem, unsigned long Maxcode = 0x10ffff,
14 // codecvt_mode Mode = (codecvt_mode)0>
15 // class codecvt_utf16
16 // : public codecvt<Elem, char, mbstate_t>
17 // {
18 // // unspecified
19 // };
21 // result
22 // in(stateT& state,
23 // const externT* from, const externT* from_end, const externT*& from_next,
24 // internT* to, internT* to_end, internT*& to_next) const;
26 #include <codecvt>
27 #include <cassert>
29 #include "test_macros.h"
31 int main(int, char**)
34 typedef std::codecvt_utf16<char32_t> C;
35 C c;
36 char32_t w = 0;
37 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
38 char32_t* wp = nullptr;
39 std::mbstate_t m;
40 const char* np = nullptr;
41 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
42 assert(r == std::codecvt_base::ok);
43 assert(wp == &w+1);
44 assert(np == n+4);
45 assert(w == 0x40003);
47 n[0] = char(0x10);
48 n[1] = char(0x05);
49 r = c.in(m, n, n+2, np, &w, &w+1, wp);
50 assert(r == std::codecvt_base::ok);
51 assert(wp == &w+1);
52 assert(np == n+2);
53 assert(w == 0x1005);
55 n[0] = char(0x04);
56 n[1] = char(0x53);
57 r = c.in(m, n, n+2, np, &w, &w+1, wp);
58 assert(r == std::codecvt_base::ok);
59 assert(wp == &w+1);
60 assert(np == n+2);
61 assert(w == 0x453);
63 w = 0x56;
64 n[0] = char(0x00);
65 n[1] = char(0x56);
66 r = c.in(m, n, n+2, np, &w, &w+1, wp);
67 assert(r == std::codecvt_base::ok);
68 assert(wp == &w+1);
69 assert(np == n+2);
70 assert(w == 0x56);
73 typedef std::codecvt_utf16<char32_t, 0x1000> C;
74 C c;
75 char32_t w = 0;
76 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
77 char32_t* wp = nullptr;
78 std::mbstate_t m;
79 const char* np = nullptr;
80 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
81 assert(r == std::codecvt_base::error);
82 assert(wp == &w);
83 assert(np == n);
84 assert(w == 0);
86 n[0] = char(0x10);
87 n[1] = char(0x05);
88 r = c.in(m, n, n+2, np, &w, &w+1, wp);
89 assert(r == std::codecvt_base::error);
90 assert(wp == &w);
91 assert(np == n);
92 assert(w == 0);
94 n[0] = char(0x04);
95 n[1] = char(0x53);
96 r = c.in(m, n, n+2, np, &w, &w+1, wp);
97 assert(r == std::codecvt_base::ok);
98 assert(wp == &w+1);
99 assert(np == n+2);
100 assert(w == 0x453);
102 w = 0x56;
103 n[0] = char(0x00);
104 n[1] = char(0x56);
105 r = c.in(m, n, n+2, np, &w, &w+1, wp);
106 assert(r == std::codecvt_base::ok);
107 assert(wp == &w+1);
108 assert(np == n+2);
109 assert(w == 0x56);
112 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
113 C c;
114 char32_t w = 0;
115 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
116 char32_t* wp = nullptr;
117 std::mbstate_t m;
118 const char* np = nullptr;
119 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
120 assert(r == std::codecvt_base::ok);
121 assert(wp == &w+1);
122 assert(np == n+6);
123 assert(w == 0x40003);
125 n[0] = char(0x10);
126 n[1] = char(0x05);
127 r = c.in(m, n, n+2, np, &w, &w+1, wp);
128 assert(r == std::codecvt_base::ok);
129 assert(wp == &w+1);
130 assert(np == n+2);
131 assert(w == 0x1005);
133 n[0] = char(0x04);
134 n[1] = char(0x53);
135 r = c.in(m, n, n+2, np, &w, &w+1, wp);
136 assert(r == std::codecvt_base::ok);
137 assert(wp == &w+1);
138 assert(np == n+2);
139 assert(w == 0x453);
141 w = 0x56;
142 n[0] = char(0x00);
143 n[1] = char(0x56);
144 r = c.in(m, n, n+2, np, &w, &w+1, wp);
145 assert(r == std::codecvt_base::ok);
146 assert(wp == &w+1);
147 assert(np == n+2);
148 assert(w == 0x56);
151 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
152 C c;
153 char32_t w = 0;
154 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
155 char32_t* wp = nullptr;
156 std::mbstate_t m;
157 const char* np = nullptr;
158 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
159 assert(r == std::codecvt_base::ok);
160 assert(wp == &w+1);
161 assert(np == n+4);
162 assert(w == 0x40003);
164 n[1] = char(0x10);
165 n[0] = char(0x05);
166 r = c.in(m, n, n+2, np, &w, &w+1, wp);
167 assert(r == std::codecvt_base::ok);
168 assert(wp == &w+1);
169 assert(np == n+2);
170 assert(w == 0x1005);
172 n[1] = char(0x04);
173 n[0] = char(0x53);
174 r = c.in(m, n, n+2, np, &w, &w+1, wp);
175 assert(r == std::codecvt_base::ok);
176 assert(wp == &w+1);
177 assert(np == n+2);
178 assert(w == 0x453);
180 w = 0x56;
181 n[1] = char(0x00);
182 n[0] = char(0x56);
183 r = c.in(m, n, n+2, np, &w, &w+1, wp);
184 assert(r == std::codecvt_base::ok);
185 assert(wp == &w+1);
186 assert(np == n+2);
187 assert(w == 0x56);
190 typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
191 C c;
192 char32_t w = 0;
193 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
194 char32_t* wp = nullptr;
195 std::mbstate_t m;
196 const char* np = nullptr;
197 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
198 assert(r == std::codecvt_base::error);
199 assert(wp == &w);
200 assert(np == n);
201 assert(w == 0);
203 n[1] = char(0x10);
204 n[0] = char(0x05);
205 r = c.in(m, n, n+2, np, &w, &w+1, wp);
206 assert(r == std::codecvt_base::error);
207 assert(wp == &w);
208 assert(np == n);
209 assert(w == 0);
211 n[1] = char(0x04);
212 n[0] = char(0x53);
213 r = c.in(m, n, n+2, np, &w, &w+1, wp);
214 assert(r == std::codecvt_base::ok);
215 assert(wp == &w+1);
216 assert(np == n+2);
217 assert(w == 0x453);
219 w = 0x56;
220 n[1] = char(0x00);
221 n[0] = char(0x56);
222 r = c.in(m, n, n+2, np, &w, &w+1, wp);
223 assert(r == std::codecvt_base::ok);
224 assert(wp == &w+1);
225 assert(np == n+2);
226 assert(w == 0x56);
229 typedef std::codecvt_utf16<char32_t, 0x10ffff,
230 std::codecvt_mode(std::consume_header | std::little_endian)> C;
232 C c;
233 char32_t w = 0;
234 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
235 char32_t* wp = nullptr;
236 std::mbstate_t m;
237 const char* np = nullptr;
238 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
239 assert(r == std::codecvt_base::ok);
240 assert(wp == &w+1);
241 assert(np == n+6);
242 assert(w == 0x40003);
244 n[1] = char(0x10);
245 n[0] = char(0x05);
246 r = c.in(m, n, n+2, np, &w, &w+1, wp);
247 assert(r == std::codecvt_base::ok);
248 assert(wp == &w+1);
249 assert(np == n+2);
250 assert(w == 0x1005);
252 n[1] = char(0x04);
253 n[0] = char(0x53);
254 r = c.in(m, n, n+2, np, &w, &w+1, wp);
255 assert(r == std::codecvt_base::ok);
256 assert(wp == &w+1);
257 assert(np == n+2);
258 assert(w == 0x453);
260 w = 0x56;
261 n[1] = char(0x00);
262 n[0] = char(0x56);
263 r = c.in(m, n, n+2, np, &w, &w+1, wp);
264 assert(r == std::codecvt_base::ok);
265 assert(wp == &w+1);
266 assert(np == n+2);
267 assert(w == 0x56);
270 typedef std::codecvt_utf16<char32_t> C;
271 C c;
272 char32_t w = 0;
273 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
274 char32_t* wp = nullptr;
275 std::mbstate_t m;
276 const char* np = nullptr;
277 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
278 assert(r == std::codecvt_base::ok);
279 assert(wp == &w+1);
280 assert(np == n+4);
281 assert(w == 0x40003);
283 n[0] = char(0x10);
284 n[1] = char(0x05);
285 r = c.in(m, n, n+2, np, &w, &w+1, wp);
286 assert(r == std::codecvt_base::ok);
287 assert(wp == &w+1);
288 assert(np == n+2);
289 assert(w == 0x1005);
291 n[0] = char(0x04);
292 n[1] = char(0x53);
293 r = c.in(m, n, n+2, np, &w, &w+1, wp);
294 assert(r == std::codecvt_base::ok);
295 assert(wp == &w+1);
296 assert(np == n+2);
297 assert(w == 0x453);
299 w = 0x56;
300 n[0] = char(0x00);
301 n[1] = char(0x56);
302 r = c.in(m, n, n+2, np, &w, &w+1, wp);
303 assert(r == std::codecvt_base::ok);
304 assert(wp == &w+1);
305 assert(np == n+2);
306 assert(w == 0x56);
309 typedef std::codecvt_utf16<char32_t, 0x1000> C;
310 C c;
311 char32_t w = 0;
312 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
313 char32_t* wp = nullptr;
314 std::mbstate_t m;
315 const char* np = nullptr;
316 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
317 assert(r == std::codecvt_base::error);
318 assert(wp == &w);
319 assert(np == n);
320 assert(w == 0);
322 n[0] = char(0x10);
323 n[1] = char(0x05);
324 r = c.in(m, n, n+2, np, &w, &w+1, wp);
325 assert(r == std::codecvt_base::error);
326 assert(wp == &w);
327 assert(np == n);
328 assert(w == 0);
330 n[0] = char(0x04);
331 n[1] = char(0x53);
332 r = c.in(m, n, n+2, np, &w, &w+1, wp);
333 assert(r == std::codecvt_base::ok);
334 assert(wp == &w+1);
335 assert(np == n+2);
336 assert(w == 0x453);
338 w = 0x56;
339 n[0] = char(0x00);
340 n[1] = char(0x56);
341 r = c.in(m, n, n+2, np, &w, &w+1, wp);
342 assert(r == std::codecvt_base::ok);
343 assert(wp == &w+1);
344 assert(np == n+2);
345 assert(w == 0x56);
348 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
349 C c;
350 char32_t w = 0;
351 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
352 char32_t* wp = nullptr;
353 std::mbstate_t m;
354 const char* np = nullptr;
355 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
356 assert(r == std::codecvt_base::ok);
357 assert(wp == &w+1);
358 assert(np == n+6);
359 assert(w == 0x40003);
361 n[0] = char(0x10);
362 n[1] = char(0x05);
363 r = c.in(m, n, n+2, np, &w, &w+1, wp);
364 assert(r == std::codecvt_base::ok);
365 assert(wp == &w+1);
366 assert(np == n+2);
367 assert(w == 0x1005);
369 n[0] = char(0x04);
370 n[1] = char(0x53);
371 r = c.in(m, n, n+2, np, &w, &w+1, wp);
372 assert(r == std::codecvt_base::ok);
373 assert(wp == &w+1);
374 assert(np == n+2);
375 assert(w == 0x453);
377 w = 0x56;
378 n[0] = char(0x00);
379 n[1] = char(0x56);
380 r = c.in(m, n, n+2, np, &w, &w+1, wp);
381 assert(r == std::codecvt_base::ok);
382 assert(wp == &w+1);
383 assert(np == n+2);
384 assert(w == 0x56);
387 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
388 C c;
389 char32_t w = 0;
390 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
391 char32_t* wp = nullptr;
392 std::mbstate_t m;
393 const char* np = nullptr;
394 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
395 assert(r == std::codecvt_base::ok);
396 assert(wp == &w+1);
397 assert(np == n+4);
398 assert(w == 0x40003);
400 n[1] = char(0x10);
401 n[0] = char(0x05);
402 r = c.in(m, n, n+2, np, &w, &w+1, wp);
403 assert(r == std::codecvt_base::ok);
404 assert(wp == &w+1);
405 assert(np == n+2);
406 assert(w == 0x1005);
408 n[1] = char(0x04);
409 n[0] = char(0x53);
410 r = c.in(m, n, n+2, np, &w, &w+1, wp);
411 assert(r == std::codecvt_base::ok);
412 assert(wp == &w+1);
413 assert(np == n+2);
414 assert(w == 0x453);
416 w = 0x56;
417 n[1] = char(0x00);
418 n[0] = char(0x56);
419 r = c.in(m, n, n+2, np, &w, &w+1, wp);
420 assert(r == std::codecvt_base::ok);
421 assert(wp == &w+1);
422 assert(np == n+2);
423 assert(w == 0x56);
426 typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
427 C c;
428 char32_t w = 0;
429 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
430 char32_t* wp = nullptr;
431 std::mbstate_t m;
432 const char* np = nullptr;
433 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
434 assert(r == std::codecvt_base::error);
435 assert(wp == &w);
436 assert(np == n);
437 assert(w == 0);
439 n[1] = char(0x10);
440 n[0] = char(0x05);
441 r = c.in(m, n, n+2, np, &w, &w+1, wp);
442 assert(r == std::codecvt_base::error);
443 assert(wp == &w);
444 assert(np == n);
445 assert(w == 0);
447 n[1] = char(0x04);
448 n[0] = char(0x53);
449 r = c.in(m, n, n+2, np, &w, &w+1, wp);
450 assert(r == std::codecvt_base::ok);
451 assert(wp == &w+1);
452 assert(np == n+2);
453 assert(w == 0x453);
455 w = 0x56;
456 n[1] = char(0x00);
457 n[0] = char(0x56);
458 r = c.in(m, n, n+2, np, &w, &w+1, wp);
459 assert(r == std::codecvt_base::ok);
460 assert(wp == &w+1);
461 assert(np == n+2);
462 assert(w == 0x56);
465 typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
466 std::consume_header |
467 std::little_endian)> C;
468 C c;
469 char32_t w = 0;
470 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
471 char32_t* wp = nullptr;
472 std::mbstate_t m;
473 const char* np = nullptr;
474 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
475 assert(r == std::codecvt_base::ok);
476 assert(wp == &w+1);
477 assert(np == n+6);
478 assert(w == 0x40003);
480 n[1] = char(0x10);
481 n[0] = char(0x05);
482 r = c.in(m, n, n+2, np, &w, &w+1, wp);
483 assert(r == std::codecvt_base::ok);
484 assert(wp == &w+1);
485 assert(np == n+2);
486 assert(w == 0x1005);
488 n[1] = char(0x04);
489 n[0] = char(0x53);
490 r = c.in(m, n, n+2, np, &w, &w+1, wp);
491 assert(r == std::codecvt_base::ok);
492 assert(wp == &w+1);
493 assert(np == n+2);
494 assert(w == 0x453);
496 w = 0x56;
497 n[1] = char(0x00);
498 n[0] = char(0x56);
499 r = c.in(m, n, n+2, np, &w, &w+1, wp);
500 assert(r == std::codecvt_base::ok);
501 assert(wp == &w+1);
502 assert(np == n+2);
503 assert(w == 0x56);
507 typedef std::codecvt_utf16<char16_t> C;
508 C c;
509 char16_t w = 0;
510 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
511 char16_t* wp = nullptr;
512 std::mbstate_t m;
513 const char* np = nullptr;
514 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
515 assert(r == std::codecvt_base::error);
516 assert(wp == &w);
517 assert(np == n);
518 assert(w == 0);
520 n[0] = char(0x10);
521 n[1] = char(0x05);
522 r = c.in(m, n, n+2, np, &w, &w+1, wp);
523 assert(r == std::codecvt_base::ok);
524 assert(wp == &w+1);
525 assert(np == n+2);
526 assert(w == 0x1005);
528 n[0] = char(0x04);
529 n[1] = char(0x53);
530 r = c.in(m, n, n+2, np, &w, &w+1, wp);
531 assert(r == std::codecvt_base::ok);
532 assert(wp == &w+1);
533 assert(np == n+2);
534 assert(w == 0x453);
536 w = 0x56;
537 n[0] = char(0x00);
538 n[1] = char(0x56);
539 r = c.in(m, n, n+2, np, &w, &w+1, wp);
540 assert(r == std::codecvt_base::ok);
541 assert(wp == &w+1);
542 assert(np == n+2);
543 assert(w == 0x56);
546 typedef std::codecvt_utf16<char16_t, 0x1000> C;
547 C c;
548 char16_t w = 0;
549 char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
550 char16_t* wp = nullptr;
551 std::mbstate_t m;
552 const char* np = nullptr;
553 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
554 assert(r == std::codecvt_base::error);
555 assert(wp == &w);
556 assert(np == n);
557 assert(w == 0);
559 n[0] = char(0x10);
560 n[1] = char(0x05);
561 r = c.in(m, n, n+2, np, &w, &w+1, wp);
562 assert(r == std::codecvt_base::error);
563 assert(wp == &w);
564 assert(np == n);
565 assert(w == 0);
567 n[0] = char(0x04);
568 n[1] = char(0x53);
569 r = c.in(m, n, n+2, np, &w, &w+1, wp);
570 assert(r == std::codecvt_base::ok);
571 assert(wp == &w+1);
572 assert(np == n+2);
573 assert(w == 0x453);
575 w = 0x56;
576 n[0] = char(0x00);
577 n[1] = char(0x56);
578 r = c.in(m, n, n+2, np, &w, &w+1, wp);
579 assert(r == std::codecvt_base::ok);
580 assert(wp == &w+1);
581 assert(np == n+2);
582 assert(w == 0x56);
585 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
586 C c;
587 char16_t w = 0;
588 char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
589 char16_t* wp = nullptr;
590 std::mbstate_t m;
591 const char* np = nullptr;
592 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
593 assert(r == std::codecvt_base::error);
594 assert(wp == &w);
595 assert(np == n+2);
596 assert(w == 0);
598 n[0] = char(0x10);
599 n[1] = char(0x05);
600 r = c.in(m, n, n+2, np, &w, &w+1, wp);
601 assert(r == std::codecvt_base::ok);
602 assert(wp == &w+1);
603 assert(np == n+2);
604 assert(w == 0x1005);
606 n[0] = char(0x04);
607 n[1] = char(0x53);
608 r = c.in(m, n, n+2, np, &w, &w+1, wp);
609 assert(r == std::codecvt_base::ok);
610 assert(wp == &w+1);
611 assert(np == n+2);
612 assert(w == 0x453);
614 w = 0x56;
615 n[0] = char(0x00);
616 n[1] = char(0x56);
617 r = c.in(m, n, n+2, np, &w, &w+1, wp);
618 assert(r == std::codecvt_base::ok);
619 assert(wp == &w+1);
620 assert(np == n+2);
621 assert(w == 0x56);
624 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
625 C c;
626 char16_t w = 0;
627 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
628 char16_t* wp = nullptr;
629 std::mbstate_t m;
630 const char* np = nullptr;
631 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
632 assert(r == std::codecvt_base::error);
633 assert(wp == &w);
634 assert(np == n);
635 assert(w == 0);
637 n[1] = char(0x10);
638 n[0] = char(0x05);
639 r = c.in(m, n, n+2, np, &w, &w+1, wp);
640 assert(r == std::codecvt_base::ok);
641 assert(wp == &w+1);
642 assert(np == n+2);
643 assert(w == 0x1005);
645 n[1] = char(0x04);
646 n[0] = char(0x53);
647 r = c.in(m, n, n+2, np, &w, &w+1, wp);
648 assert(r == std::codecvt_base::ok);
649 assert(wp == &w+1);
650 assert(np == n+2);
651 assert(w == 0x453);
653 w = 0x56;
654 n[1] = char(0x00);
655 n[0] = char(0x56);
656 r = c.in(m, n, n+2, np, &w, &w+1, wp);
657 assert(r == std::codecvt_base::ok);
658 assert(wp == &w+1);
659 assert(np == n+2);
660 assert(w == 0x56);
663 typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
664 C c;
665 char16_t w = 0;
666 char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
667 char16_t* wp = nullptr;
668 std::mbstate_t m;
669 const char* np = nullptr;
670 std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
671 assert(r == std::codecvt_base::error);
672 assert(wp == &w);
673 assert(np == n);
674 assert(w == 0);
676 n[1] = char(0x10);
677 n[0] = char(0x05);
678 r = c.in(m, n, n+2, np, &w, &w+1, wp);
679 assert(r == std::codecvt_base::error);
680 assert(wp == &w);
681 assert(np == n);
682 assert(w == 0);
684 n[1] = char(0x04);
685 n[0] = char(0x53);
686 r = c.in(m, n, n+2, np, &w, &w+1, wp);
687 assert(r == std::codecvt_base::ok);
688 assert(wp == &w+1);
689 assert(np == n+2);
690 assert(w == 0x453);
692 w = 0x56;
693 n[1] = char(0x00);
694 n[0] = char(0x56);
695 r = c.in(m, n, n+2, np, &w, &w+1, wp);
696 assert(r == std::codecvt_base::ok);
697 assert(wp == &w+1);
698 assert(np == n+2);
699 assert(w == 0x56);
702 typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
703 std::consume_header |
704 std::little_endian)> C;
705 C c;
706 char16_t w = 0;
707 char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
708 char16_t* wp = nullptr;
709 std::mbstate_t m;
710 const char* np = nullptr;
711 std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
712 assert(r == std::codecvt_base::error);
713 assert(wp == &w);
714 assert(np == n+2);
715 assert(w == 0);
717 n[1] = char(0x10);
718 n[0] = char(0x05);
719 r = c.in(m, n, n+2, np, &w, &w+1, wp);
720 assert(r == std::codecvt_base::ok);
721 assert(wp == &w+1);
722 assert(np == n+2);
723 assert(w == 0x1005);
725 n[1] = char(0x04);
726 n[0] = char(0x53);
727 r = c.in(m, n, n+2, np, &w, &w+1, wp);
728 assert(r == std::codecvt_base::ok);
729 assert(wp == &w+1);
730 assert(np == n+2);
731 assert(w == 0x453);
733 w = 0x56;
734 n[1] = char(0x00);
735 n[0] = char(0x56);
736 r = c.in(m, n, n+2, np, &w, &w+1, wp);
737 assert(r == std::codecvt_base::ok);
738 assert(wp == &w+1);
739 assert(np == n+2);
740 assert(w == 0x56);
743 return 0;