]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/66417.cc
1 // Copyright (C) 2015-2020 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
21 #include <testsuite_hooks.h>
28 constexpr auto mode
= generate_header
;
29 codecvt_utf16
<char32_t
, 0x10ffff, mode
> cvt
;
31 const char32_t
* from
= U
"ABC";
32 const char32_t
* from_next
;
36 cvt
.out(state
, from
, from
+ 3, from_next
, to
, to
+ 100, to_next
);
38 VERIFY((unsigned char)to
[0] == 0xfe);
39 VERIFY((unsigned char)to
[1] == 0xff);
40 VERIFY(to
[2] == 0x00);
41 VERIFY(to
[3] == 0x41);
42 VERIFY(to
[4] == 0x00);
43 VERIFY(to
[5] == 0x42);
44 VERIFY(to
[6] == 0x00);
45 VERIFY(to
[7] == 0x43);
51 constexpr auto mode
= codecvt_mode(generate_header
|little_endian
);
52 codecvt_utf16
<char32_t
, 0x10ffff, mode
> cvt
;
54 const char32_t
* from
= U
"ABC";
55 const char32_t
* from_next
;
59 cvt
.out(state
, from
, from
+ 3, from_next
, to
, to
+ 100, to_next
);
61 VERIFY((unsigned char)to
[0] == 0xff);
62 VERIFY((unsigned char)to
[1] == 0xfe);
63 VERIFY(to
[2] == 0x41);
64 VERIFY(to
[3] == 0x00);
65 VERIFY(to
[4] == 0x42);
66 VERIFY(to
[5] == 0x00);
67 VERIFY(to
[6] == 0x43);
68 VERIFY(to
[7] == 0x00);