1.cc: Remove 'test' variables.
[official-gcc.git] / libstdc++-v3 / testsuite / ext / codecvt / 1.cc
blob48d243c48a1c36bcf0ac31becf2db35b59dae688
1 // { dg-require-iconv "UCS-2BE" }
2 // { dg-require-iconv "ISO-8859-15" }
3 // 2003-02-06 Petur Runolfsson <peturr02@ru.is>
5 // Copyright (C) 2003-2016 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
24 #include <locale>
25 #include <cstring>
26 #include <testsuite_hooks.h>
27 #include <ext/codecvt_specializations.h>
29 // Partial specialization using encoding_state
30 // codecvt<unicode_t, char, encoding_state>
31 // UNICODE - UCS2 (big endian)
32 void test01()
34 using namespace std;
35 typedef unsigned short int_type;
36 typedef char ext_type;
37 typedef __gnu_cxx::encoding_state state_type;
38 typedef codecvt<int_type, ext_type, state_type> unicode_codecvt;
40 const ext_type* e_lit = "black pearl jasmine tea";
41 int size = strlen(e_lit);
43 // construct a locale object with the specialized facet.
44 locale loc(locale::classic(), new unicode_codecvt);
45 // sanity check the constructed locale has the specialized facet.
46 VERIFY( has_facet<unicode_codecvt>(loc) );
47 const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
49 unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0xfeff, 0);
50 cvt.length(state04, e_lit, e_lit + size, 5);
53 int main ()
55 test01();
56 return 0;