diff options
Diffstat (limited to 'libstdc++-v3/testsuite/27_io')
130 files changed, 1587 insertions, 152 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/2.cc index af92af0ff11..5005c17f4b4 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/2.cc @@ -33,7 +33,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_filebuf<type_t, char_traits<type_t> >; template class basic_filebuf<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc index de6e1339a0e..434f1e2312d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc @@ -42,7 +42,7 @@ void test02() VERIFY( p != bad); // 1 "if file is not positioned at its beginning" fails... - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/9322.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/9322.cc index 5a43a2a4a2f..efe8cbbeea0 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/9322.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/9322.cc @@ -34,10 +34,10 @@ void test07() std::filebuf ob; VERIFY( ob.getloc() == loc ); - locale::global(__gnu_cxx_test::try_named_locale("en_US")); + locale::global(__gnu_test::try_named_locale("en_US")); VERIFY( ob.getloc() == loc ); - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc_de ); VERIFY( ret == loc ); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc index 4acff8123e7..7fe0d4cc65b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc @@ -42,7 +42,7 @@ void test02() VERIFY( p != bad); // 1 "if file is not positioned at its beginning" fails... - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc index 1b083fd023a..8a76a997c9a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc @@ -34,10 +34,10 @@ void test07() std::wfilebuf ob; VERIFY( ob.getloc() == loc ); - locale::global(__gnu_cxx_test::try_named_locale("en_US")); + locale::global(__gnu_test::try_named_locale("en_US")); VERIFY( ob.getloc() == loc ); - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc_de ); VERIFY( ret == loc ); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc index 185fb1ed658..fc96a047fdf 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc @@ -28,7 +28,7 @@ void test01() bool test = true; wfilebuf fb; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fb.pubimbue(loc); fb.pubsetbuf(0, 0); fb.open("tmp_11305-1", ios_base::out); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc index f50f59218cd..2415a2edcfb 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc @@ -28,7 +28,7 @@ void test02() bool test = true; wfilebuf fb; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fb.pubimbue(loc); fb.pubsetbuf(0, 0); fb.open("tmp_11305-2", ios_base::out); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc index 86153ea1ff0..fc0092df09c 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc @@ -28,7 +28,7 @@ void test03() bool test = true; wfilebuf fb; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fb.pubimbue(loc); fb.open("tmp_11305-3", ios_base::out); wfilebuf::int_type n1 = fb.sputc(L'a'); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc index b923a8a9e70..1886f8e630f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc @@ -28,7 +28,7 @@ void test04() bool test = true; wfilebuf fb; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fb.pubimbue(loc); fb.open("tmp_11405-4", ios_base::out); wfilebuf::int_type n1 = fb.sputc(L'i'); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc index e03da5f2064..f1b30d8de1a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc index 451518c1f23..f649ef87dc6 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sbumpc_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc index 69559a9a69c..1a43f327dca 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sbumpc_1out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc index d0f256ee10c..e06e0625efb 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc index ef1f28f786e..54a3047ad00 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sbumpc_2io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc index 1d8df086bcc..a650e8eab96 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sbumpc_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc index 62173d0c843..2da27f13dcd 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff.txt"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc index 00872f4117d..a655fd81ab7 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff-1io.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc index 39abdac89d3..40c62aafe25 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff-1out.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc index 0dc97ded28a..a1adf32b8be 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff.txt"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc index 8be6f5e7adf..fd30a33007d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff-2io.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc index 4a39a2164f3..786fb245a16 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekoff-2out.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/1.cc new file mode 100644 index 00000000000..f3f3cc712d4 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/1.cc @@ -0,0 +1,136 @@ +// 2003-09-08 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <fstream> +#include <locale> +#include <cstdio> +#include <testsuite_hooks.h> + +// Check that basic_filebuf::seekoff handles UTF-8 when open for input. +void test01() +{ + using namespace std; + typedef wfilebuf::pos_type pos_type; + typedef wfilebuf::int_type int_type; + + bool test = true; + const char name[] = "tmp_seekoff-1.tst"; + const int_type eof = wfilebuf::traits_type::eof(); + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + const int loops = 2 * BUFSIZ / wlen; + locale loc = __gnu_test::try_named_locale("se_NO.UTF-8"); + + FILE* file = fopen(name, "w"); + for (int i = 0; i < loops; ++i) + fwrite(cstr, 1, clen, file); + fclose(file); + + wfilebuf fb; + fb.pubimbue(loc); + fb.open(name, ios_base::in); + + pos_type p1 = fb.pubseekoff(0, ios_base::cur); + pos_type end = fb.pubseekoff(0, ios_base::end); + pos_type beg = fb.pubseekoff(0, ios_base::beg); + VERIFY( p1 == beg ); + + const size_t limit = wlen * loops; + for (size_t index = 0; index < limit; ++index) + { + // Call seekoff at pseudo-random intervals. + if (index % 5 == 0 || index % 7 == 0) + { + pos_type p2 = fb.pubseekoff(0, ios_base::cur); + VERIFY( p2 != pos_type(-1) ); + } + int_type c1 = fb.sbumpc(); + VERIFY( c1 != eof ); + VERIFY( c1 == wstr[index % wlen] ); + } + + pos_type p3 = fb.pubseekoff(0, ios_base::cur); + VERIFY( p3 == end ); + + int_type c2 = fb.sbumpc(); + VERIFY( c2 == eof ); + + fb.close(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/2.cc new file mode 100644 index 00000000000..9ad978bee9f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/2.cc @@ -0,0 +1,89 @@ +// 2003-09-08 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <fstream> +#include <locale> +#include <cstdio> +#include <testsuite_hooks.h> + +// Check that basic_filebuf::seekoff handles UTF-8 when open for input and +// output. +void test02() +{ + using namespace std; + typedef wfilebuf::int_type int_type; + bool test = true; + const char name[] = "tmp_seekoff-2.tst"; + + locale loc = __gnu_test::try_named_locale("se_NO.UTF-8"); + + const size_t size = 10; + wchar_t buf[size]; + streamsize n; + + wfilebuf fb; + fb.pubimbue(loc); + fb.open(name, ios_base::in | ios_base::out | ios_base::trunc); + + n = fb.sputn(L"\xa0st", 3); + VERIFY( n == 3 ); + + fb.pubseekoff(0, ios_base::beg); + n = fb.sgetn(buf, 2); + VERIFY( n == 2 ); + VERIFY( !wmemcmp(buf, L"\xa0s", 2) ); + + fb.pubseekoff(0, ios_base::cur); + n = fb.sputn(L"\xb2R", 2); + VERIFY( n == 2 ); + + fb.pubseekoff(0, ios_base::beg); + n = fb.sgetn(buf, size); + VERIFY( n == 4 ); + VERIFY( !wmemcmp(buf, L"\xa0s\xb2R", 4) ); + + fb.pubseekoff(0, ios_base::beg); + n = fb.sputn(L"\x90m\x92n\x94", 5); + VERIFY( n == 5 ); + + fb.pubseekoff(0, ios_base::beg); + n = fb.sgetn(buf, 2); + VERIFY( n == 2 ); + VERIFY( !wmemcmp(buf, L"\x90m", 2) ); + + fb.pubseekoff(0, ios_base::end); + n = fb.sputn(L"I\xbfJ", 3); + VERIFY( n == 3 ); + + fb.pubseekoff(0, ios_base::beg); + n = fb.sgetn(buf, size); + VERIFY( n == 8 ); + VERIFY( !wmemcmp(buf, L"\x90m\x92n\x94I\xbfJ", 8) ); + + fb.close(); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc index 9464eefc1d3..3230e121ed2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc index 009886032aa..ecaa19fb2d8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos-1io.tst"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc index b0008f3cb43..e3c9ac3f3f3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos-1out.tst"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc index ec1dca5abb8..2fde41aed9e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc index f883cf9ef3a..71fb68bf3ff 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos-2io.tst"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc index 9531e01c609..ee8c65f5154 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc @@ -32,7 +32,7 @@ const char name_01[] = "seekpos-2out.tst"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::pos_type pos_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc index 2927991c060..f7a65870df4 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc @@ -34,7 +34,9 @@ void test02() filebuf fbuf01; fbuf01.open("tmp", ios_base::out); - fbuf01.pubsetbuf(buf, strlitsize); + // NB: +2 otherwise sputn is optimized to a direct write, + // bypassing the buffer. + fbuf01.pubsetbuf(buf, strlitsize + 2); fbuf01.sputn(strlit, strlitsize); VERIFY( std::strncmp(strlit, buf, strlitsize) == 0 ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc index 7ae7cdccee4..2a1012d812e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc index 7a754768002..ca92295456e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_sgetc_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc index 41e18e435e4..cdd9bf47051 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc @@ -33,7 +33,7 @@ const char name_02[] = "tmp_sgetc_1out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc index 979a3fd3845..3c539de1840 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc index e12ef3455cd..09b6e8a7f0a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_sgetc_2io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc index 491c028c281..1db40febda2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc @@ -33,7 +33,7 @@ const char name_02[] = "tmp_sgetc_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc index 0f17624c58c..523bdeac34b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetn.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc index e1d9a38f75e..9942a822b26 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_sgetn_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc index eb710f2d056..1039c397303 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc @@ -33,7 +33,7 @@ const char name_02[] = "tmp_sgetn_1out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc index 62c5a0f93f0..451e6dcfee3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetn.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc index 30ccee29f2e..a3fd754e36d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_sgetn_2io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc index 99a907493d4..c0e6be07443 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc @@ -33,7 +33,7 @@ const char name_02[] = "tmp_sgetn_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc index 437a7fb6535..d2d9d3b1c55 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc index aa5000d987a..973d89b41f3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc index 118383a978e..fd7124a1448 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc @@ -34,7 +34,7 @@ const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc index 8c563ad41e8..fc89dd5e644 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc index a044c6d4f41..8c2c0e868e5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_snextc_2io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc index 8af126337f6..816c3f85406 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_snextc_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc index bd6e2055eff..1d216e8ec20 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc index f43191cc730..d867e5b87a2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "tmp_sputbackc_1io.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc index 83d57e2fc61..5b5dbb557c1 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc @@ -33,7 +33,7 @@ const char name_01[] = "tmp_sputbackc_1out.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc index 5deafbc7da7..a9267cf0034 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc index 093c663db3a..e7166106d59 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "tmp_sputbackc_2io.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc index 52f041d8af9..2ff9a6c5aad 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc @@ -33,7 +33,7 @@ const char name_01[] = "tmp_sputbackc_2out.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc index 25d9ee0ce8d..31b176bcbf6 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc index 72350c0a8b8..275def18397 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sputc_1io.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc index f4b5b73f0e7..09086b07d60 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sputc_1out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc index 85ab4efbeff..680e058a904 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc index 373a6a8cba5..abbdea55fbd 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sputc_2io.tst"; void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc index 96e12954a97..78e2b4eb3d6 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sputc_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc index 235fce07e22..4888f23bb16 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc index 9ec3d259ca8..7f32662d315 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sputn_1io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc index f98bcd745b1..d17db7abf3b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sputn_1out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc index 8972b5efcb8..a9f188cf410 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc @@ -32,7 +32,7 @@ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc index c6109c2f100..2dc0204c94e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc @@ -33,7 +33,7 @@ const char name_03[] = "tmp_sputn_2io.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc index 81cd506aba1..26046b17a35 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc @@ -32,7 +32,7 @@ const char name_02[] = "tmp_sputn_2out.tst"; // empty file, need to create void test05() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc index bf753cabcb6..7e3b9c07621 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc index 78464834bec..5cbaf1b8db2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "tmp_sungetc_1io.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc index 99cf7ed383c..daefb70b997 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc @@ -33,7 +33,7 @@ const char name_01[] = "tmp_sungetc_1out.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc index e0814fdddc0..d35a3f2ae8b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc @@ -33,7 +33,7 @@ const char name_01[] = "sgetc.txt"; // file with data in it void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc index 24d015c90e7..b45ba2676bf 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc @@ -32,7 +32,7 @@ const char name_01[] = "tmp_sungetc_2io.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc index d6cd79f5c6e..f08df15e7b8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc @@ -33,7 +33,7 @@ const char name_01[] = "tmp_sungetc_2out.tst"; // empty file, need to create void test01() { using namespace std; - using namespace __gnu_cxx_test; + using namespace __gnu_test; typedef std::filebuf::int_type int_type; typedef filebuf::traits_type traits_type; diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/1.cc new file mode 100644 index 00000000000..d55b89c90ac --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/1.cc @@ -0,0 +1,110 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <locale> +#include <fstream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handing of UTF-8 in basic_filebuf::underflow +void test01() +{ + using namespace std; + bool test = true; + const char name[] = "tmp_underflow-1.tst"; + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + locale loc = __gnu_test::try_named_locale("se_NO.UTF-8"); + + FILE* file = fopen(name, "w"); + fwrite(cstr, 1, clen, file); + fclose(file); + + wchar_t wbuf[wlen + 1]; + + wfilebuf fb; + fb.pubimbue(loc); + fb.open(name, ios_base::in); + streamsize n = fb.sgetn(wbuf, wlen + 1); + fb.close(); + + VERIFY( n == wlen ); + VERIFY( !wmemcmp(wbuf, wstr, wlen) ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-1.cc index c4866ef3d97..d0753650d12 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-1.cc @@ -34,7 +34,7 @@ void test01() fbout.close(); wfilebuf fbin; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fbin.pubimbue(loc); fbin.open(name_01, ios_base::in); VERIFY( fbin.sbumpc() == L'a' ); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-2.cc index 90dfb8fd1fd..1717f2a5aeb 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-2.cc @@ -35,7 +35,7 @@ void test02() fbout.close(); wfilebuf fbin; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fbin.pubimbue(loc); fbin.open(name_02, ios_base::in); VERIFY( fbin.sbumpc() == L'a' ); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-3.cc index c4b48597919..c23cb56f26b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-3.cc @@ -34,7 +34,7 @@ void test03() fbout.close(); wfilebuf fbin; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fbin.pubimbue(loc); fbin.pubsetbuf(0, 0); fbin.open(name_03, ios_base::in); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-4.cc index 00d1edc2f05..ec2f0f89245 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11389-4.cc @@ -35,7 +35,7 @@ void test04() fbout.close(); wfilebuf fbin; - locale loc(__gnu_cxx_test::try_named_locale("en_US.UTF-8")); + locale loc(__gnu_test::try_named_locale("en_US.UTF-8")); fbin.pubimbue(loc); fbin.pubsetbuf(0, 0); fbin.open(name_04, ios_base::in); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/2.cc new file mode 100644 index 00000000000..77616ed5d91 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/2.cc @@ -0,0 +1,111 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <locale> +#include <fstream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handing of UTF-8 in unbuffered basic_filebuf::underflow +void test02() +{ + using namespace std; + bool test = true; + const char name[] = "tmp_underflow-2.tst"; + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + locale loc = __gnu_test::try_named_locale("se_NO.UTF-8"); + + FILE* file = fopen(name, "w"); + fwrite(cstr, 1, clen, file); + fclose(file); + + wchar_t wbuf[wlen + 1]; + + wfilebuf fb; + fb.pubimbue(loc); + fb.pubsetbuf(0, 0); + fb.open(name, ios_base::in); + streamsize n = fb.sgetn(wbuf, wlen + 1); + fb.close(); + + VERIFY( n == wlen ); + VERIFY( !wmemcmp(wbuf, wstr, wlen) ); +} + +int main () +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/3.cc new file mode 100644 index 00000000000..169d3ebfa25 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/3.cc @@ -0,0 +1,116 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <locale> +#include <fstream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handing of UTF-8 in basic_filebuf::underflow +void test03() +{ + using namespace std; + bool test = true; + const char name[] = "tmp_underflow-3.tst"; + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + const int loops = 2 * BUFSIZ / wlen; + locale loc = __gnu_test::try_named_locale("se_NO.UTF-8"); + + FILE* file = fopen(name, "w"); + for (int i = 0; i < loops; ++i) + fwrite(cstr, 1, clen, file); + fclose(file); + + wchar_t wbuf[wlen]; + + wfilebuf fb; + fb.pubimbue(loc); + fb.open(name, ios_base::in); + for (int i = 0; i < loops; ++i) + { + streamsize n = fb.sgetn(wbuf, wlen); + VERIFY( n == wlen ); + VERIFY( !wmemcmp(wbuf, wstr, wlen) ); + } + + VERIFY( fb.sgetc() == wfilebuf::traits_type::eof() ); + fb.close(); +} + +int main () +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/4.cc new file mode 100644 index 00000000000..00fb3774489 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/4.cc @@ -0,0 +1,54 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> +// Adapted from 27_io/basic_filebuf/underflow/char/2.cc + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <fstream> +#include <locale> +#include <testsuite_hooks.h> + +void test01() +{ + bool test = true; + using namespace std; + + locale loc (__gnu_test::try_named_locale("se_NO.UTF-8")); + wfilebuf fb_out, fb_in_out; + fb_out.pubimbue(loc); + fb_in_out.pubimbue(loc); + + fb_out.open("tmp_underflow.tst", ios::out); + fb_out.sputc(L'S'); + fb_out.sputc(L'T'); + fb_out.close(); + + fb_in_out.open("tmp_underflow.tst", ios::in | ios::out); + while (fb_in_out.sbumpc() != filebuf::traits_type::eof()); + + VERIFY( fb_in_out.sputc(L'x') == L'x' ); + fb_in_out.close(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/5.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/5.cc new file mode 100644 index 00000000000..f8636b0cc30 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/5.cc @@ -0,0 +1,73 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <locale> +#include <fstream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test that unbuffered really means unbuffered for UTF-8 +void test05() +{ + using namespace std; + bool test = true; + const char* name = "tmp_underflow-5"; + + wfilebuf fb; + fb.pubsetbuf(0, 0); + fb.pubimbue(__gnu_test::try_named_locale("se_NO.UTF-8")); + + FILE* file = fopen(name, "w"); + setvbuf(file, 0, _IONBF, 0); + fputs("abcde", file); + + fb.open(name, ios_base::in); + VERIFY( fb.sbumpc() == L'a' ); + + fseek(file, 1, SEEK_SET); + fputc('0', file); + + VERIFY( fb.sbumpc() == L'0' ); + VERIFY( fb.sbumpc() == L'c' ); + + fputc('1', file); + fputc('2', file); + + VERIFY( fb.sbumpc() == L'2' ); + VERIFY( fb.sbumpc() == L'e' ); + VERIFY( fb.sbumpc() == WEOF ); + + fputc('3', file); + fputc('4', file); + + VERIFY( fb.sbumpc() == L'4' ); + VERIFY( fb.sbumpc() == WEOF ); + + fb.close(); + fclose(file); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc index a764bb2b5de..5bd831378d7 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc @@ -35,7 +35,7 @@ void test01() putc(static_cast<unsigned char>(i), file); fclose(file); - locale loc (__gnu_cxx_test::try_named_locale("de_DE.ISO-8859-15@euro")); + locale loc (__gnu_test::try_named_locale("de_DE.ISO-8859-15@euro")); wchar_t buf[1]; wfilebuf fb; fb.pubimbue(loc); diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/2.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/2.cc index 3faf03f4dcf..861a6044f9e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_fstream/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_fstream/2.cc @@ -38,7 +38,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_fstream<type_t, char_traits<type_t> >; template class basic_fstream<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/2.cc index 6daa4e02c5e..3286411eb62 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/2.cc @@ -43,7 +43,7 @@ void test03() typedef std::ios_base::fmtflags fmtflags; typedef std::ios_base::iostate iostate; locale loc_c = locale::classic(); - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); std::ios ios_01(NULL); std::ios ios_02(NULL); ios_01.imbue(loc_c); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/2.cc index 40ec332923d..7676f6a094e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/2.cc @@ -38,7 +38,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_istream<type_t, char_traits<type_t> >; template class basic_istream<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc index b2fdd2691e7..9c3b3605cb8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc @@ -119,11 +119,6 @@ bool test01() { ss_01 >> pi; std::printf ("%x %x\n", pi, po); VERIFY( po == pi ); - -#ifdef DEBUG_ASSERT - assert(test); -#endif - return test; } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc index 374fbd8e0c7..94136d2e168 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc @@ -56,11 +56,6 @@ bool test02() { VERIFY( n == 20000 ); char c = is.peek(); VERIFY( c == 65 ); - -#ifdef DEBUG_ASSERT - assert(test); -#endif - return test; } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc index 869d828b091..65306c4d6e3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc @@ -55,11 +55,6 @@ bool test03() istr >> l01; // _M_in_end set completely incorrectly here. VERIFY( l01 == 12220101 ); VERIFY( istr.rdstate() == std::ios_base::eofbit ); - -#ifdef DEBUG_ASSERT - assert(test); -#endif - return test; } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc index de92bcd52cb..206c81e506b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc @@ -70,10 +70,6 @@ void test06() is >> c; // EOF VERIFY( c == ',' ); VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) ); - -#ifdef DEBUG_ASSERT - assert(test); -#endif } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc index 118668ea1d9..6167471ba49 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc @@ -156,10 +156,6 @@ void test07() VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) ); VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) ); is.clear(); - -#ifdef DEBUG_ASSERT - assert(test); -#endif } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc index f8491612ddf..2a2c3cc1ff7 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc @@ -79,11 +79,6 @@ void test08() is >> h2; VERIFY( h2 == 2212322 ); VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) ); - - -#ifdef DEBUG_ASSERT - assert(test); -#endif } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc index 37e175e6f7c..67d98d53de8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc @@ -58,10 +58,6 @@ bool test09() test = f1 == 2456; VERIFY( f2 == 0.00567 ); VERIFY( c == '-' ); -#ifdef DEBUG_ASSERT - assert(test); -#endif - return test; } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc index bc67190533f..de7bbf9ada8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc @@ -139,11 +139,6 @@ bool test10() { is_05.ignore(); is_05 >> n; VERIFY( n == 16 ); - -#ifdef DEBUG_ASSERT - assert(test); -#endif - return test; } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc index 9d59395bde4..157084167f5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc @@ -39,7 +39,7 @@ void test02() { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; basic_stringstream<pod_char, char_traits<pod_char> > sstr; // 1 diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc index 99dd0b09bc1..27e1e3667ff 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc @@ -30,6 +30,7 @@ // 27.4.2.1.6 class ios_base::init #include <fstream> +#include <typeinfo> #include <testsuite_hooks.h> // char_traits specialization diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-sstream.cc index 6f51df5850d..4e928fad62b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-sstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-sstream.cc @@ -30,6 +30,7 @@ // 27.4.2.1.6 class ios_base::init #include <sstream> +#include <typeinfo> #include <testsuite_hooks.h> // char_traits specialization diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/2.cc index 8c672b1f076..3910aa7bd34 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/2.cc @@ -38,7 +38,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_ostream<type_t, char_traits<type_t> >; template class basic_ostream<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc index 8a81b964fd1..f49f60405f8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc @@ -30,7 +30,7 @@ using namespace std; -#ifndef DEBUG_ASSERT +#ifndef _GLIBCXX_ASSERT # define TEST_NUMPUT_VERBOSE 1 #endif diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc index 92180927f6f..2cf4021108f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc @@ -43,7 +43,7 @@ test02() os2.setf(ios::fixed); // Check it can be done in a locale with grouping on. - locale loc2 = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc2 = __gnu_test::try_named_locale("de_DE"); os2.imbue(loc2); os2 << fixed << setprecision(3) << val2 << endl; os2 << endl; diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc index a439c9e78ab..484e66b8c15 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc @@ -30,7 +30,7 @@ using namespace std; -#ifndef DEBUG_ASSERT +#ifndef _GLIBCXX_ASSERT # define TEST_NUMPUT_VERBOSE 1 #endif diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc index 3cdf3b83310..2c8f6c67463 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc @@ -30,6 +30,7 @@ // 27.4.2.1.6 class ios_base::init #include <fstream> +#include <typeinfo> #include <testsuite_hooks.h> // char_traits specialization diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-sstream.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-sstream.cc index 5f68c585ad5..141548ad10a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-sstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-sstream.cc @@ -30,6 +30,7 @@ // 27.4.2.1.6 class ios_base::init #include <sstream> +#include <typeinfo> #include <testsuite_hooks.h> // char_traits specialization diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/2.cc index b3a48269bf4..71da9a59349 100644 --- a/libstdc++-v3/testsuite/27_io/basic_streambuf/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/2.cc @@ -38,7 +38,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_streambuf<type_t, char_traits<type_t> >; template class basic_streambuf<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc index fee82668f9d..7dbfdc75562 100644 --- a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc @@ -53,10 +53,10 @@ void test08() testbuf ob; VERIFY( ob.getloc() == loc ); - locale::global(__gnu_cxx_test::try_named_locale("en_US")); + locale::global(__gnu_test::try_named_locale("en_US")); VERIFY( ob.getloc() == loc ); - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc_de ); VERIFY( ret == loc ); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/1.cc index a91deab2f1d..7841f3275c5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/1.cc @@ -50,7 +50,7 @@ void test01() namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_stringbuf<type_t, char_traits<type_t> >; template class basic_stringbuf<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/2.cc index f40868a179f..940aa7a852a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/2.cc @@ -33,7 +33,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_stringbuf<type_t, char_traits<type_t> >; template class basic_stringbuf<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc index cd4c4311c6a..fd2ddbd6acc 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc @@ -30,8 +30,8 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; - typedef __gnu_cxx_test::tracker_alloc<char> alloc_type; + using __gnu_test::pod_char; + typedef __gnu_test::tracker_alloc<char> alloc_type; template class basic_stringbuf<char, char_traits<char>, alloc_type>; } // test diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/imbue/char/9322.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/imbue/char/9322.cc index 7006dda094a..549e59ef841 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/imbue/char/9322.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/imbue/char/9322.cc @@ -33,10 +33,10 @@ void test03() std::stringbuf ob; VERIFY( ob.getloc() == loc ); - locale::global(__gnu_cxx_test::try_named_locale("en_US")); + locale::global(__gnu_test::try_named_locale("en_US")); VERIFY( ob.getloc() == loc ); - locale loc_de = __gnu_cxx_test::try_named_locale("de_DE"); + locale loc_de = __gnu_test::try_named_locale("de_DE"); locale ret = ob.pubimbue(loc_de); VERIFY( ob.getloc() == loc_de ); VERIFY( ret == loc ); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/2.cc index abadf8271e6..5cd55f1d30b 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/2.cc @@ -38,7 +38,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class basic_stringstream<type_t, char_traits<type_t> >; template class basic_stringstream<pod_char, char_traits<pod_char> >; diff --git a/libstdc++-v3/testsuite/27_io/fpos/1.cc b/libstdc++-v3/testsuite/27_io/fpos/1.cc index 5d074c1e270..8d927dc51e1 100644 --- a/libstdc++-v3/testsuite/27_io/fpos/1.cc +++ b/libstdc++-v3/testsuite/27_io/fpos/1.cc @@ -28,7 +28,7 @@ namespace test { using namespace std; - using __gnu_cxx_test::pod_char; + using __gnu_test::pod_char; typedef short type_t; template class fpos<type_t>; template class fpos<pod_char>; diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc index e6f9921b368..f0baf752ef7 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc @@ -41,5 +41,5 @@ void test01() io1 = io2; } // { dg-error "within this context" "" { target *-*-* } 41 } -// { dg-error "is private" "" { target *-*-* } 696 } +// { dg-error "is private" "" { target *-*-* } 748 } // { dg-error "operator=" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc index 5d77444b342..08865db583e 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc @@ -41,5 +41,5 @@ void test02() test_base io2 = io1; } // { dg-error "within this context" "" { target *-*-* } 41 } -// { dg-error "is private" "" { target *-*-* } 693 } +// { dg-error "is private" "" { target *-*-* } 745 } // { dg-error "copy constructor" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/1.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/1.cc index dac74cd35da..ee27d44788c 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/1.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/1.cc @@ -48,7 +48,7 @@ void test01() int main(void) { - __gnu_cxx_test::set_memory_limits(); + __gnu_test::set_memory_limits(); test01(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc index 751b6be2583..7df7eb965b4 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc @@ -123,7 +123,7 @@ void test02() int main(void) { - __gnu_cxx_test::set_memory_limits(); + __gnu_test::set_memory_limits(); test02(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/3.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/3.cc index 2c9816a397e..ea5e13a422a 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/3.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/3.cc @@ -46,7 +46,7 @@ void test03() int main(void) { - __gnu_cxx_test::set_memory_limits(); + __gnu_test::set_memory_limits(); test03(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc new file mode 100644 index 00000000000..7ad336dafe6 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc @@ -0,0 +1,43 @@ +// Derived from libstdc++/12048 by LJR <ljrittle@acm.org> with +// reminder from Petur Runolfsson <peturr02@ru.is>. + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + char c1; + char c2; + std::cin.get(c1); + std::cin.unget(); + std::cin.get(c2); + VERIFY( std::cin.good() ); + VERIFY( c1 == c2 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc new file mode 100644 index 00000000000..d544d644065 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + char c1; + int c2; + std::cin.get(c1); + std::cin.unget(); + VERIFY( std::cin.good() ); + c2 = std::fgetc(stdin); + VERIFY( c2 == std::char_traits<char>::to_int_type(c1) ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc new file mode 100644 index 00000000000..2f69b072233 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + char buf[2]; + VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 ); + int c1 = std::cin.rdbuf()->sungetc(); + int c2 = std::cin.rdbuf()->sbumpc(); + VERIFY( c1 == std::char_traits<char>::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc new file mode 100644 index 00000000000..6c0b28fe4db --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + char buf[2]; + VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 ); + int c1 = std::cin.rdbuf()->sungetc(); + int c2 = std::fgetc(stdin); + VERIFY( c1 == std::char_traits<char>::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc new file mode 100644 index 00000000000..884f49e9010 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc @@ -0,0 +1,55 @@ +// Derived from libstdc++/12048 by LJR <ljrittle@acm.org> with +// reminder from Petur Runolfsson <peturr02@ru.is>. + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// DR 49 states that cin.rdbuf()->sbumpc() and fgetc(stdin) should be +// equivalent and interchangable. Currently however, cin.rdbuf()->sungetc() +// only returns characters that were read with cin.rdbuf()->sbumpc() + +// { dg-do run { xfail *-*-* } } + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + char c1; + int c2; + char c3; + std::cin.get(c1); + c2 = std::fgetc(stdin); + std::cin.unget(); + if (std::cin.good()) + { + std::cin.get(c3); + VERIFY( std::cin.good() ); + VERIFY( c3 == std::char_traits<char>::to_char_type(c2) ); + } +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc index f0a7868ba4f..f797380836f 100644 --- a/libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc @@ -22,7 +22,7 @@ #include <cstdio> #include <testsuite_hooks.h> -// Test handling of UTF-8 in wcin and wcout +// Test handling of UTF-8 in wcin void test10() { using namespace std; @@ -30,7 +30,7 @@ void test10() bool test = true; const char* name = "tmp_10"; - locale loc(__gnu_cxx_test::try_named_locale("se_NO.UTF-8")); + locale loc(__gnu_test::try_named_locale("se_NO.UTF-8")); locale::global(loc); wcin.imbue(loc); wcout.imbue(loc); @@ -87,18 +87,9 @@ void test10() }; size_t i_size = wcslen(i_lit); - freopen(name, "w", stdout); - - wcout.write(i_lit, i_size); - wcout.flush(); - VERIFY( wcout.good() ); - - FILE* file = fopen(name, "r"); - char* buf = new char[e_size + 10]; - size_t n = fread(buf, 1, e_size + 10, file); + FILE* file = fopen(name, "w"); + size_t n = fwrite(e_lit, 1, e_size, file); VERIFY( n == e_size ); - VERIFY( !memcmp(buf, e_lit, e_size) ); - delete[] buf; fclose(file); freopen(name, "r", stdin); diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc new file mode 100644 index 00000000000..d538612a60d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc @@ -0,0 +1,109 @@ +// 2003-05-01 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handling of UTF-8 in wcout +void test11() +{ + using namespace std; + + bool test = true; + const char* name = "tmp_11"; + + locale loc(__gnu_test::try_named_locale("se_NO.UTF-8")); + locale::global(loc); + wcin.imbue(loc); + wcout.imbue(loc); + + const char* e_lit = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + size_t e_size = strlen(e_lit); + + const wchar_t i_lit[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + size_t i_size = wcslen(i_lit); + + freopen(name, "w", stdout); + + wcout.write(i_lit, i_size); + wcout.flush(); + VERIFY( wcout.good() ); + + FILE* file = fopen(name, "r"); + char* buf = new char[e_size + 10]; + size_t n = fread(buf, 1, e_size + 10, file); + VERIFY( n == e_size ); + VERIFY( !memcmp(buf, e_lit, e_size) ); + delete[] buf; + fclose(file); +} + +int main() +{ + test11(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12.cc new file mode 100644 index 00000000000..50e4e78cd8c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12.cc @@ -0,0 +1,119 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handling of UTF-8 in wcout +void test12() +{ + using namespace std; + + bool test = true; + const char* name = "tmp_12"; + + locale loc(__gnu_test::try_named_locale("se_NO.UTF-8")); + locale::global(loc); + std::ios_base::sync_with_stdio(false); + wcout.imbue(loc); + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + int fd = open(name, + O_WRONLY | O_CREAT | O_TRUNC, + 0666); + VERIFY( fd != -1 ); + VERIFY( dup2(fd, 1) == 1 ); + close(fd); + + wcout.write(wstr, wlen); + wcout.flush(); + VERIFY( wcout.good() ); + + FILE* file = fopen(name, "r"); + char buf[clen + 10]; + size_t n = fread(buf, 1, clen + 10, file); + VERIFY( n == clen ); + VERIFY( !memcmp(buf, cstr, clen) ); + fclose(file); +} + +int main() +{ + test12(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc new file mode 100644 index 00000000000..dbdf1d12f7e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc @@ -0,0 +1,43 @@ +// Derived from libstdc++/12048 by LJR <ljrittle@acm.org> with +// reminder from Petur Runolfsson <peturr02@ru.is>. + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + wchar_t c1; + wchar_t c2; + std::wcin.get(c1); + std::wcin.unget(); + std::wcin.get(c2); + VERIFY( std::wcin.good() ); + VERIFY( c1 == c2 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc new file mode 100644 index 00000000000..f96302ad292 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cstdio> +#include <cwchar> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + wchar_t c1; + std::wint_t c2; + std::wcin.get(c1); + std::wcin.unget(); + VERIFY( std::wcin.good() ); + c2 = std::fgetwc(stdin); + VERIFY( c2 == std::char_traits<wchar_t>::to_int_type(c1) ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc new file mode 100644 index 00000000000..568b6a1409a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc @@ -0,0 +1,43 @@ +// Derived from libstdc++/12048 by LJR <ljrittle@acm.org> with +// reminder from Petur Runolfsson <peturr02@ru.is>. + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cwchar> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + wchar_t buf[2]; + VERIFY( std::wcin.rdbuf()->sgetn(buf, 2) == 2 ); + std::wint_t c1 = std::wcin.rdbuf()->sungetc(); + std::wint_t c2 = std::wcin.rdbuf()->sbumpc(); + VERIFY( c1 == std::char_traits<wchar_t>::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc new file mode 100644 index 00000000000..5096cd055e3 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <iostream> +#include <cstdio> +#include <cwchar> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + wchar_t buf[2]; + VERIFY( std::wcin.rdbuf()->sgetn(buf, 2) == 2 ); + wint_t c1 = std::wcin.rdbuf()->sungetc(); + wint_t c2 = std::fgetwc(stdin); + VERIFY( c1 == std::char_traits<wchar_t>::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc new file mode 100644 index 00000000000..bc965fd35f9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// DR 49 states that cin.rdbuf()->sbumpc() and fgetc(stdin) should be +// equivalent and interchangable. Currently however, cin.rdbuf()->sungetc() +// only returns characters that were read with cin.rdbuf()->sbumpc() + +// { dg-do run { xfail *-*-* } } + +#include <iostream> +#include <cstdio> +#include <cwchar> +#include <testsuite_hooks.h> + +void +test01() +{ + std::freopen("cin_unget-1.txt", "r", stdin); + + wchar_t c1; + std::wint_t c2; + wchar_t c3; + std::wcin.get(c1); + c2 = std::fgetwc(stdin); + std::wcin.unget(); + if (std::wcin.good()) + { + std::wcin.get(c3); + VERIFY( std::wcin.good() ); + VERIFY( c3 == std::char_traits<wchar_t>::to_char_type(c2) ); + } +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/13.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/13.cc new file mode 100644 index 00000000000..b974b4afb85 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/13.cc @@ -0,0 +1,118 @@ +// 2003-09-04 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <iostream> +#include <cstdio> +#include <testsuite_hooks.h> + +// Test handling of UTF-8 in wcin +void test13() +{ + using namespace std; + + bool test = true; + const char* name = "tmp_13"; + + locale loc(__gnu_test::try_named_locale("se_NO.UTF-8")); + locale::global(loc); + std::ios_base::sync_with_stdio(false); + wcin.imbue(loc); + + const char cstr[] = + "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&" + "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2" + "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a" + "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2" + "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99" + "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3" + "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85" + "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4" + "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94" + "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf" + "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0" + "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0" + "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0" + "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0" + "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0" + "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80" + "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80" + "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1" + "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80" + "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80" + "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80" + "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80" + "\xfd\x80\x80\x80\x80\x80"; + + const wchar_t wstr[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!', + L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+', + L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5', + L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?', + L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100, + 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, + 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112, + 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9, + 0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802, + 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b, + 0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814, + 0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@', + 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, + 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, + 0x20000000, 0x40000000, 0x0 + }; + + const size_t clen = sizeof(cstr) / sizeof(cstr[0]); + const size_t wlen = sizeof(wstr) / sizeof(wstr[0]); + + FILE* file = fopen(name, "w"); + fwrite(cstr, 1, clen, file); + fclose(file); + + int fd = open(name, O_RDONLY); + dup2(fd, 0); + close(fd); + + wchar_t wbuf[wlen + 10]; + wcin.read(wbuf, wlen + 10); + streamsize n = wcin.gcount(); + VERIFY( n == wlen ); + VERIFY( !wmemcmp(wbuf, wstr, wlen) ); + VERIFY( wcin.eof() ); + VERIFY( wcin.fail() ); + VERIFY( !wcin.bad() ); +} + +int main() +{ + test13(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc index 835282fe449..79d087840c5 100644 --- a/libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc @@ -34,7 +34,7 @@ void test01() putc(static_cast<unsigned char>(i), file); fclose(file); - locale loc (__gnu_cxx_test::try_named_locale("de_DE.ISO-8859-15@euro")); + locale loc (__gnu_test::try_named_locale("de_DE.ISO-8859-15@euro")); locale::global(loc); // Set locale for stdin freopen(name, "r", stdin); |