OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [imbue/] [wchar_t/] [13582-2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// { dg-require-namedlocale "" }
2
// { dg-require-fork "" }
3
// { dg-require-mkfifo "" }
4
 
5
// 2004-01-11  Petur Runolfsson  <peturr02@ru.is>
6
 
7
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
8
//
9
// This file is part of the GNU ISO C++ Library.  This library is free
10
// software; you can redistribute it and/or modify it under the
11
// terms of the GNU General Public License as published by the
12
// Free Software Foundation; either version 2, or (at your option)
13
// any later version.
14
 
15
// This library is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
// GNU General Public License for more details.
19
 
20
// You should have received a copy of the GNU General Public License along
21
// with this library; see the file COPYING.  If not, write to the Free
22
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23
// USA.
24
 
25
// 27.8.1.4 Overridden virtual functions
26
 
27
#include <fstream>
28
#include <locale>
29
 
30
#include <unistd.h>
31
#include <sys/types.h>
32
#include <sys/stat.h>
33
 
34
#include <testsuite_hooks.h>
35
 
36
// libstdc++/13582
37
void test01()
38
{
39
  bool test __attribute__((unused)) = true;
40
  using namespace std;
41
  using namespace __gnu_test;
42
 
43
  locale loc_en(locale("en_US"));
44
  locale loc_fr(locale("fr_FR"));
45
 
46
  const char* name = "tmp_fifo_13582-2";
47
  unlink(name);
48
  mkfifo(name, S_IRWXU);
49
 
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();
57
      sleep(2);
58
      fbout.close();
59
      exit(0);
60
    }
61
 
62
  wfilebuf fbin;
63
  fbin.open(name, ios_base::in);
64
  sleep(1);
65
  wfilebuf::int_type n = fbin.sbumpc();
66
  VERIFY( n == L'1' );
67
  fbin.pubimbue(loc_en);
68
  n = fbin.sbumpc();
69
  VERIFY( n == L'2' );
70
  fbin.pubimbue(loc_fr);
71
  n = fbin.sbumpc();
72
  VERIFY( n == L'3' );
73
  n = fbin.sbumpc();
74
  VERIFY( n == L'4' );
75
  n = fbin.sbumpc();
76
  VERIFY( n == L'5' );
77
  n = fbin.sbumpc();
78
  VERIFY( n == wfilebuf::traits_type::eof() );
79
}
80
 
81
int main()
82
{
83
  test01();
84
  return 0;
85
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.