]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/80041.cc
1 // Copyright (C) 2017-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>
26 #ifdef _GLIBCXX_USE_WCHAR_T
27 std::codecvt_utf16
<wchar_t> conv
;
28 const wchar_t wc
= 0x6557;
30 const wchar_t* wcnext
;
33 auto res
= conv
.out(st
, &wc
, &wc
+ 1, wcnext
, bytes
, std::end(bytes
), next
);
34 VERIFY( res
== std::codecvt_base::ok
);
35 VERIFY( wcnext
== &wc
+ 1 );
36 VERIFY( next
== std::end(bytes
) );
37 VERIFY( bytes
[0] == 0x65 );
38 VERIFY( bytes
[1] == 0x57 );
39 VERIFY( conv
.length(st
, bytes
, next
, 1) == (next
- bytes
) );
45 res
= conv
.in(st
, bytes
, next
, cnext
, &w
, &w
+ 1, wnext
);
46 VERIFY( res
== std::codecvt_base::ok
);
47 VERIFY( wnext
== &w
+ 1 );
48 VERIFY( cnext
== next
);
56 #ifdef _GLIBCXX_USE_WCHAR_T
57 std::codecvt_utf16
<wchar_t, 0x10FFFF, std::little_endian
> conv
;
60 const wchar_t* wcnext
;
63 auto res
= conv
.out(st
, &wc
, &wc
+ 1, wcnext
, bytes
, std::end(bytes
), next
);
64 VERIFY( res
== std::codecvt_base::ok
);
65 VERIFY( wcnext
== &wc
+ 1 );
66 VERIFY( next
== std::end(bytes
) );
67 VERIFY( bytes
[0] == 0x57 );
68 VERIFY( bytes
[1] == 0x65 );
69 VERIFY( conv
.length(st
, bytes
, next
, 1) == (next
- bytes
) );
75 res
= conv
.in(st
, bytes
, next
, cnext
, &w
, &w
+ 1, wnext
);
76 VERIFY( res
== std::codecvt_base::ok
);
77 VERIFY( wnext
== &w
+ 1 );
78 VERIFY( cnext
== next
);