]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc
2398829b12bf60e1028df330034a45d81ea2ae2a
1 // Copyright (C) 2015-2019 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 } }
24 #include <testsuite_hooks.h>
29 // convert from UCS-4 to UTF16BE with BOM.
30 using cvt
= std::codecvt_utf16
<char32_t
, 0x10FFFF, std::generate_header
>;
31 std::wstring_convert
<cvt
, char32_t
> conv
;
32 auto to
= conv
.to_bytes(U
"ab\u00e7");
34 VERIFY( to
.length() == 8 );
35 VERIFY( (unsigned char)to
[0] == 0xfe );
36 VERIFY( (unsigned char)to
[1] == 0xff );
37 VERIFY( (unsigned char)to
[2] == 0x00 );
38 VERIFY( (unsigned char)to
[3] == 0x61 );
39 VERIFY( (unsigned char)to
[4] == 0x00 );
40 VERIFY( (unsigned char)to
[5] == 0x62 );
41 VERIFY( (unsigned char)to
[6] == 0x00 );
42 VERIFY( (unsigned char)to
[7] == 0xe7 );