]>
Commit | Line | Data |
---|---|---|
4216708a JM |
1 | // { dg-require-namedlocale "en_US.ISO8859-1" } |
2 | // { dg-require-namedlocale "fr_FR.ISO8859-15" } | |
34f4edf8 MM |
3 | // { dg-require-fork "" } |
4 | // { dg-require-mkfifo "" } | |
5 | ||
09625c16 PC |
6 | // 2004-01-11 Petur Runolfsson <peturr02@ru.is> |
7 | ||
8d9254fc | 8 | // Copyright (C) 2004-2020 Free Software Foundation, Inc. |
09625c16 PC |
9 | // |
10 | // This file is part of the GNU ISO C++ Library. This library is free | |
11 | // software; you can redistribute it and/or modify it under the | |
12 | // terms of the GNU General Public License as published by the | |
748086b7 | 13 | // Free Software Foundation; either version 3, or (at your option) |
09625c16 PC |
14 | // any later version. |
15 | ||
16 | // This library is distributed in the hope that it will be useful, | |
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | // GNU General Public License for more details. | |
20 | ||
21 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
22 | // with this library; see the file COPYING3. If not see |
23 | // <http://www.gnu.org/licenses/>. | |
09625c16 PC |
24 | |
25 | // 27.8.1.4 Overridden virtual functions | |
26 | ||
27 | #include <fstream> | |
28 | #include <locale> | |
debac9f4 | 29 | #include <cstdlib> |
09625c16 PC |
30 | |
31 | #include <unistd.h> | |
32 | #include <sys/types.h> | |
33 | #include <sys/stat.h> | |
34 | ||
35 | #include <testsuite_hooks.h> | |
36 | ||
37 | // libstdc++/13582 | |
38 | void test01() | |
39 | { | |
09625c16 | 40 | using namespace std; |
300b3317 | 41 | using namespace __gnu_test; |
09625c16 | 42 | |
4216708a JM |
43 | locale loc_en(locale(ISO_8859(1,en_US))); |
44 | locale loc_fr(locale(ISO_8859(15,fr_FR))); | |
09625c16 PC |
45 | |
46 | const char* name = "tmp_fifo_13582-2"; | |
47 | unlink(name); | |
34f4edf8 | 48 | mkfifo(name, S_IRWXU); |
8f1032c1 | 49 | |
09625c16 PC |
50 | int child = fork(); |
51 | if (child == 0) | |
52 | { | |
53 | filebuf fbout; | |
54 | fbout.open(name, ios_base::out); | |
55 | fbout.sputn("12345", 5); | |
56 | fbout.pubsync(); | |
09625c16 PC |
57 | fbout.close(); |
58 | exit(0); | |
59 | } | |
60 | ||
61 | filebuf fbin; | |
62 | fbin.open(name, ios_base::in); | |
09625c16 PC |
63 | filebuf::int_type n = fbin.sbumpc(); |
64 | VERIFY( n == '1' ); | |
65 | fbin.pubimbue(loc_en); | |
66 | n = fbin.sbumpc(); | |
67 | VERIFY( n == '2' ); | |
68 | fbin.pubimbue(loc_fr); | |
69 | n = fbin.sbumpc(); | |
70 | VERIFY( n == '3' ); | |
71 | n = fbin.sbumpc(); | |
72 | VERIFY( n == '4' ); | |
73 | n = fbin.sbumpc(); | |
74 | VERIFY( n == '5' ); | |
75 | n = fbin.sbumpc(); | |
76 | VERIFY( n == filebuf::traits_type::eof() ); | |
77 | } | |
78 | ||
79 | int main() | |
80 | { | |
81 | test01(); | |
82 | return 0; | |
83 | } |