Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / imbue / wchar_t / 14975-2.cc
blob2e6f9ec414944c3adc19eb754dc46ac46dd8a3ab
1 // 2004-04-16 Petur Runolfsson <peturr02@ru.is>
3 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 #include <fstream>
22 #include <locale>
23 #include <unistd.h>
24 #include <signal.h>
25 #include <fcntl.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <testsuite_hooks.h>
30 // libstdc++/14975
31 void test01()
33 using namespace std;
34 using namespace __gnu_test;
35 bool test __attribute__((unused)) = true;
37 locale loc_us = try_named_locale("en_US");
39 const char* name = "tmp_14975-2";
41 signal(SIGPIPE, SIG_IGN);
43 unlink(name);
44 try_mkfifo(name, S_IRWXU);
45 semaphore s1;
47 int child = fork();
48 VERIFY( child != -1 );
50 if (child == 0)
53 filebuf fbin;
54 fbin.open(name, ios_base::in);
56 s1.signal ();
57 exit(0);
60 wfilebuf fb;
61 fb.pubimbue(loc_us);
62 wfilebuf* ret = fb.open(name, ios_base::out);
63 VERIFY( ret != NULL );
64 VERIFY( fb.is_open() );
66 s1.wait ();
68 try
70 fb.sputc(L'a');
71 fb.sputc(L'b');
72 fb.pubimbue(locale::classic());
73 fb.sputc(L'c');
74 fb.close();
76 catch (std::exception&)
81 int main()
83 test01();
84 return 0;