Debian Codegraph @

libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_char8_t.cc

raw
1 // Copyright (C) 2020-2025 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 // { dg-require-cstdint "" }
20 // { dg-options "-fchar8_t" }
21
22 #include "codecvt_unicode.h"
23
24 using namespace std;
25
26 void
27 test_utf8_utf32_codecvts ()
28 {
29 using codecvt_c32_c8 = codecvt<char32_t, char8_t, mbstate_t>;
30 auto &loc_c = locale::classic ();
31 VERIFY (has_facet<codecvt_c32_c8> (loc_c));
32
33 auto &cvt = use_facet<codecvt_c32_c8> (loc_c);
34 test_utf8_utf32_cvt (cvt);
35 }
36
37 void
38 test_utf8_utf16_codecvts ()
39 {
40 using codecvt_c16_c8 = codecvt<char16_t, char8_t, mbstate_t>;
41 auto &loc_c = locale::classic ();
42 VERIFY (has_facet<codecvt_c16_c8> (loc_c));
43
44 auto &cvt = use_facet<codecvt_c16_c8> (loc_c);
45 test_utf8_utf16_cvt (cvt);
46 }
47
48 int
49 main ()
50 {
51 test_utf8_utf32_codecvts ();
52 test_utf8_utf16_codecvts ();
53 }