Rebase.
[official-gcc.git] / libstdc++-v3 / testsuite / ext / enc_filebuf / char / 13598.cc
blob403fb6d176949a12f59c11ac86bfe703bb7d6347
1 // Before Solaris 11, iconv -f ISO-8859-1 -t ISO-8859-1 fails with
2 // Not supported ISO-8859-1 to ISO-8859-1
3 //
4 // { dg-do run { xfail *-*-solaris2.10 } }
5 // { dg-require-iconv "ISO-8859-1" }
7 // Copyright (C) 2004-2014 Free Software Foundation, Inc.
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
13 // any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
24 #include <locale>
25 #include <cstring>
26 #include <cstddef>
27 #include <testsuite_hooks.h>
28 #include <ext/enc_filebuf.h>
30 int main()
32 bool test __attribute__((unused)) = true;
33 typedef char char_type;
34 typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
35 typedef filebuf_type::state_type state_type;
37 const char* str = "Hello, world!\n";
38 std::locale loc(std::locale::classic(),
39 new std::codecvt<char, char, __gnu_cxx::encoding_state>());
40 state_type st("ISO-8859-1", "ISO-8859-1");
41 filebuf_type fb(st);
42 fb.pubimbue(loc);
44 fb.open("tmp_13598", std::ios_base::out);
45 std::streamsize n = fb.sputn(str, std::strlen(str));
46 int s = fb.pubsync();
47 fb.close();
49 VERIFY( std::size_t(n) == std::strlen(str) );
50 VERIFY( s == 0 );
52 return 0;