1 // { dg-require-iconv "ISO-8859-1" }
3 // Copyright (C) 2006-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
22 #include <cwchar> // for mbstate_t
26 #include <testsuite_hooks.h>
27 #include <ext/codecvt_specializations.h>
29 typedef std::codecvt
<char, char, std::mbstate_t> c_codecvt
;
31 #ifdef _GLIBCXX_USE_WCHAR_T
32 typedef std::codecvt
<wchar_t, char, std::mbstate_t> w_codecvt
;
35 class gnu_facet
: public std::locale::facet
38 static std::locale::id id
;
41 std::locale::id
gnu_facet::id
;
46 typedef unsigned short int_type
;
47 typedef char ext_type
;
48 typedef __gnu_cxx::encoding_state state_type
;
49 typedef codecvt
<int_type
, ext_type
, state_type
> unicode_codecvt
;
51 bool test
__attribute__((unused
)) = true;
54 locale
loc01(locale::classic());
55 locale
loc13(locale::classic(), new unicode_codecvt
);
56 VERIFY( loc01
!= loc13
);
57 VERIFY( loc13
.name() == "*" );
60 VERIFY( has_facet
<c_codecvt
>(loc13
) );
61 #ifdef _GLIBCXX_USE_WCHAR_T
62 VERIFY( has_facet
<w_codecvt
>(loc13
) );
64 VERIFY( has_facet
<unicode_codecvt
>(loc13
) );
70 { use_facet
<gnu_facet
>(loc13
); }