]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / codecvt / codecvt_utf8 / wchar_t / 1.cc
1 // Copyright (C) 2018-2019 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
8
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.
13
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/>.
17
18 // { dg-do run { target c++11 } }
19
20 #include <string>
21 #include <codecvt>
22 #include <testsuite_hooks.h>
23
24 void
25 test01()
26 {
27 const char out[] = u8"\u00A33.50";
28 wchar_t in[8] = {};
29 std::codecvt_utf8<wchar_t> cvt;
30 std::mbstate_t st;
31 const char* no;
32 wchar_t* ni;
33 auto res = cvt.in(st, out, out+6, no, in, in+8, ni);
34 VERIFY( res == std::codecvt_base::ok );
35 VERIFY( in[1] == L'3' );
36 VERIFY( in[2] == L'.' );
37 VERIFY( in[3] == L'5' );
38 VERIFY( in[4] == L'0' );
39
40 char out2[8] = {};
41 char* no2;
42 const wchar_t* ni2;
43 res = cvt.out(st, in, ni, ni2, out2, out2+8, no2);
44 VERIFY( res == std::codecvt_base::ok );
45 VERIFY( out2 == std::string(out) );
46 }
47
48 int
49 main()
50 {
51 test01();
52 }