summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/1.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/12868.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc62
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13171-3.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-2.cc86
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-3.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc95
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/3.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc55
10 files changed, 646 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/1.cc
new file mode 100644
index 000000000..f5c6daac3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/1.cc
@@ -0,0 +1,44 @@
+// 981208 bkoz test functionality of basic_stringbuf for char_type == char
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+std::wfilebuf fbuf;
+
+// test the filebuf locale settings
+void test02()
+{
+ std::locale loc_c = std::locale::classic();
+ loc_c = fbuf.getloc();
+ fbuf.pubimbue(loc_c); //This should initialize _M_init to true
+ std::locale loc_tmp = fbuf.getloc();
+ VERIFY( loc_tmp == loc_c );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
+
+// more candy!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/12868.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/12868.cc
new file mode 100644
index 000000000..bc7c3c1bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/12868.cc
@@ -0,0 +1,61 @@
+// { dg-require-namedlocale "is_IS.UTF-8" }
+
+// Copyright (C) 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <ostream>
+#include <fstream>
+#include <locale>
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/12868
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc_is(locale("is_IS.UTF-8"));
+
+ {
+ wofstream out("tmp_12868");
+ out << L"<? xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
+ out.imbue(loc_is);
+ VERIFY( out.rdbuf()->getloc() == loc_is );
+ out << L"<greeting>Hall\u00f3 heimur</greeting>\n";
+ }
+
+ {
+ wifstream in("tmp_12868");
+ wstring str;
+ getline(in, str);
+ if (str.find(L"encoding=\"UTF-8\"") != wstring::npos)
+ {
+ in.imbue(loc_is);
+ VERIFY( in.rdbuf()->getloc() == loc_is );
+ }
+ getline(in, str);
+ VERIFY( str == L"<greeting>Hall\u00f3 heimur</greeting>" );
+ }
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc
new file mode 100644
index 000000000..9bb1f4035
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc
@@ -0,0 +1,62 @@
+// { dg-require-namedlocale "fr_FR" }
+
+// Copyright (C) 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf : public std::wfilebuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::wfilebuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf buf;
+ std::locale loc(std::locale("fr_FR"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13171-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13171-3.cc
new file mode 100644
index 000000000..ec11237d0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13171-3.cc
@@ -0,0 +1,59 @@
+// { dg-require-namedlocale "fr_FR" }
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "de_DE" }
+
+// Copyright (C) 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <iostream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// libstdc++/13171
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ locale::global(locale("fr_FR"));
+
+ ios_base::sync_with_stdio(false);
+
+ locale::global(locale("en_US"));
+ cin.imbue(locale("en_US"));
+ cout.imbue(locale("en_US"));
+ cerr.imbue(locale("en_US"));
+ clog.imbue(locale("de_DE"));
+ wcin.imbue(locale("en_US"));
+ wcout.imbue(locale("en_US"));
+ wcerr.imbue(locale("en_US"));
+ wclog.imbue(locale("de_DE"));
+
+ cout << 'f' << endl;
+ cerr << 'r' << endl;
+ clog << 'A' << endl;
+ wcout << L's' << endl;
+ wcerr << L'i' << endl;
+ wclog << L'L' << endl;
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-2.cc
new file mode 100644
index 000000000..7a997739f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-2.cc
@@ -0,0 +1,86 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "fr_FR" }
+// { dg-require-fork "" }
+// { dg-require-mkfifo "" }
+
+// 2004-01-11 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <cstdlib>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <testsuite_hooks.h>
+
+// libstdc++/13582
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ using namespace __gnu_test;
+
+ locale loc_en(locale("en_US"));
+ locale loc_fr(locale("fr_FR"));
+
+ const char* name = "tmp_fifo_13582-2";
+ unlink(name);
+ mkfifo(name, S_IRWXU);
+
+ int child = fork();
+ if (child == 0)
+ {
+ filebuf fbout;
+ fbout.open(name, ios_base::out);
+ fbout.sputn("12345", 5);
+ fbout.pubsync();
+ sleep(2);
+ fbout.close();
+ exit(0);
+ }
+
+ wfilebuf fbin;
+ fbin.open(name, ios_base::in);
+ sleep(1);
+ wfilebuf::int_type n = fbin.sbumpc();
+ VERIFY( n == L'1' );
+ fbin.pubimbue(loc_en);
+ n = fbin.sbumpc();
+ VERIFY( n == L'2' );
+ fbin.pubimbue(loc_fr);
+ n = fbin.sbumpc();
+ VERIFY( n == L'3' );
+ n = fbin.sbumpc();
+ VERIFY( n == L'4' );
+ n = fbin.sbumpc();
+ VERIFY( n == L'5' );
+ n = fbin.sbumpc();
+ VERIFY( n == wfilebuf::traits_type::eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-3.cc
new file mode 100644
index 000000000..246ae8c6e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-3.cc
@@ -0,0 +1,74 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "fr_FR" }
+
+// 2004-01-11 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2004, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// libstdc++/13582
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ locale loc_en(locale("en_US"));
+ locale loc_fr(locale("fr_FR"));
+
+ const char* name = "tmp_13582-3.tst";
+
+ {
+ filebuf fbout;
+ fbout.open(name, ios_base::out);
+ fbout.sputn("AbCdE", 5);
+ fbout.close();
+ }
+
+ {
+ wfilebuf fbin;
+ fbin.open(name, ios_base::in);
+ wfilebuf::int_type n = fbin.sbumpc();
+ VERIFY( n == L'A' );
+ fbin.pubimbue(loc_en);
+ fbin.pubseekoff(0, ios_base::cur);
+ n = fbin.sbumpc();
+ VERIFY( n == L'b' );
+ fbin.pubimbue(loc_fr);
+ n = fbin.sbumpc();
+ VERIFY( n == L'C' );
+ n = fbin.sbumpc();
+ VERIFY( n == L'd' );
+ fbin.pubseekoff(0, ios_base::cur);
+ n = fbin.sbumpc();
+ VERIFY( n == L'E' );
+ n = fbin.sbumpc();
+ VERIFY( n == wfilebuf::traits_type::eof() );
+ fbin.close();
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc
new file mode 100644
index 000000000..dc1314556
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc
@@ -0,0 +1,95 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-fork "" }
+// { dg-require-mkfifo "" }
+
+// 2004-04-16 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <fstream>
+#include <locale>
+#include <cstdlib>
+#include <unistd.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+// No asserts, avoid leaking the semaphore if a VERIFY fails.
+#undef _GLIBCXX_ASSERT
+
+#include <testsuite_hooks.h>
+
+// libstdc++/14975
+bool test01()
+{
+ using namespace std;
+ using namespace __gnu_test;
+ bool test __attribute__((unused)) = true;
+
+ locale loc_us = locale("en_US");
+
+ const char* name = "tmp_14975-2";
+
+ signal(SIGPIPE, SIG_IGN);
+
+ unlink(name);
+ mkfifo(name, S_IRWXU);
+ semaphore s1;
+
+ int child = fork();
+ VERIFY( child != -1 );
+
+ if (child == 0)
+ {
+ {
+ filebuf fbin;
+ fbin.open(name, ios_base::in);
+ }
+ s1.signal();
+ exit(0);
+ }
+
+ wfilebuf fb;
+ fb.pubimbue(loc_us);
+ wfilebuf* ret = fb.open(name, ios_base::out);
+ VERIFY( ret != 0 );
+ VERIFY( fb.is_open() );
+
+ s1.wait();
+
+ try
+ {
+ fb.sputc(L'a');
+ fb.sputc(L'b');
+ fb.pubimbue(locale::classic());
+ fb.sputc(L'c');
+ fb.close();
+ }
+ catch (std::exception&)
+ {
+ }
+
+ return test;
+}
+
+int main()
+{
+ return !test01();
+}
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
new file mode 100644
index 000000000..52941a5fc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc
@@ -0,0 +1,55 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2003-05-13 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+ locale loc;
+ wfilebuf ob;
+ VERIFY( ob.getloc() == loc );
+ ob.open(name_01, ios_base::in);
+ VERIFY( ob.is_open() );
+
+ typedef streambuf::pos_type pos_type;
+ pos_type bad = pos_type(streambuf::off_type(-1));
+ pos_type p = ob.pubseekoff(2, ios_base::beg, ios_base::in);
+ VERIFY( p != bad);
+
+ // According to 27.5.2.2.1, p1, loc == getloc() after pubimbue(loc).
+ locale loc_de = locale("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/3.cc
new file mode 100644
index 000000000..01baec6b5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/3.cc
@@ -0,0 +1,55 @@
+// 2003-05-13 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class state_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t>
+{
+protected:
+ int
+ do_encoding() const throw()
+ { return -1; }
+};
+
+void test03()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc_s(locale::classic(), new state_codecvt);
+ wfilebuf ob;
+ ob.pubimbue(loc_s);
+ VERIFY( ob.getloc() == loc_s );
+
+ // 2 "if encoding of current locale is state dependent" and
+ // not at the beginning of the file fails...
+ locale loc_c = locale::classic();
+ locale ret = ob.pubimbue(loc_s);
+ VERIFY( ob.getloc() == loc_s );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
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
new file mode 100644
index 000000000..f69d9f0d6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/9322.cc
@@ -0,0 +1,55 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "de_DE" }
+
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// libstdc++/9322
+void test07()
+{
+ using std::locale;
+ bool test __attribute__((unused)) = true;
+
+ locale loc;
+ std::wfilebuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de = locale("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}