| 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 | |
| 20 | #include "codecvt_unicode.h" |
| 21 | |
| 22 | #include <codecvt> |
| 23 | |
| 24 | using namespace std; |
| 25 | |
| 26 | void |
| 27 | test_utf8_utf32_codecvts () |
| 28 | { |
| 29 | #if __SIZEOF_WCHAR_T__ == 4 |
| 30 | codecvt_utf8<wchar_t> cvt; |
| 31 | test_utf8_utf32_cvt (cvt); |
| 32 | #endif |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | test_utf8_utf16_codecvts () |
| 37 | { |
| 38 | #if __SIZEOF_WCHAR_T__ >= 2 |
| 39 | codecvt_utf8_utf16<wchar_t> cvt; |
| 40 | test_utf8_utf16_cvt (cvt); |
| 41 | #endif |
| 42 | } |
| 43 | |
| 44 | void |
| 45 | test_utf8_ucs2_codecvts () |
| 46 | { |
| 47 | #if __SIZEOF_WCHAR_T__ == 2 |
| 48 | codecvt_utf8<wchar_t> cvt; |
| 49 | test_utf8_ucs2_cvt (cvt); |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | test_utf16_utf32_codecvts () |
| 55 | { |
| 56 | #if __SIZEOF_WCHAR_T__ == 4 |
| 57 | codecvt_utf16<wchar_t> cvt3; |
| 58 | test_utf16_utf32_cvt (cvt3, utf16_big_endian); |
| 59 | |
| 60 | codecvt_utf16<wchar_t, 0x10FFFF, codecvt_mode::little_endian> cvt4; |
| 61 | test_utf16_utf32_cvt (cvt4, utf16_little_endian); |
| 62 | #endif |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | test_utf16_ucs2_codecvts () |
| 67 | { |
| 68 | #if __SIZEOF_WCHAR_T__ == 2 |
| 69 | codecvt_utf16<wchar_t> cvt3; |
| 70 | test_utf16_ucs2_cvt (cvt3, utf16_big_endian); |
| 71 | |
| 72 | codecvt_utf16<wchar_t, 0x10FFFF, codecvt_mode::little_endian> cvt4; |
| 73 | test_utf16_ucs2_cvt (cvt4, utf16_little_endian); |
| 74 | #endif |
| 75 | } |
| 76 | |
| 77 | int |
| 78 | main () |
| 79 | { |
| 80 | test_utf8_utf32_codecvts (); |
| 81 | test_utf8_utf16_codecvts (); |
| 82 | test_utf8_ucs2_codecvts (); |
| 83 | test_utf16_utf32_codecvts (); |
| 84 | test_utf16_ucs2_codecvts (); |
| 85 | } |