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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [sentry/] [pod/] [1.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// 1999-10-14 bkoz
2
 
3
// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4
// 2009, 2010
5
// Free Software Foundation, Inc.
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
 
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
 
23
// 27.6.1.1.2 class basic_istream::sentry
24
 
25
#include <ostream>
26
#include <sstream>
27
#include <typeinfo>
28
#include <ext/pod_char_traits.h>
29
#include <testsuite_hooks.h>
30
#include <testsuite_character.h>
31
 
32
void test01()
33
{
34
  using namespace std;
35
  using __gnu_test::pod_ushort;
36
  typedef basic_string<pod_ushort>      string_type;
37
  typedef basic_stringbuf<pod_ushort>   stringbuf_type;
38
  typedef basic_ostream<pod_ushort>     ostream_type;
39
 
40
  bool test __attribute__((unused)) = true;
41
 
42
 
43
  const string_type str01;
44
  stringbuf_type* strbuf01 = 0;
45
  stringbuf_type strbuf02(str01);
46
  ostream_type ostr01(strbuf01);
47
  ostream_type ostr02(&strbuf02);
48
 
49
  // test negatives
50
  try
51
    {
52
      ostream_type::sentry sentry01(ostr01);
53
    }
54
  catch (std::bad_cast& obj)
55
    {
56
      // Not ok, throws bad_cast because locale has no ctype facet,
57
      // but none is needed for ostream::sentry.
58
      VERIFY( false );
59
    }
60
  catch (...)
61
    {
62
      VERIFY( false );
63
    }
64
 
65
  // imbued.
66
  const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
67
  ostr01.imbue(loc);
68
  try
69
    {
70
      ostream_type::sentry sentry01(ostr01);
71
      VERIFY( bool(sentry01) == false );
72
    }
73
  catch (...)
74
    {
75
      VERIFY( false );
76
    }
77
 
78
  // test positive 
79
  try
80
    {
81
      ostream_type::sentry sentry03(ostr02);
82
    }
83
  catch (std::bad_cast& obj)
84
    {
85
      // Not ok, throws bad_cast because locale has no ctype facet,
86
      // but none is needed for ostream::sentry.
87
      VERIFY( false );
88
    }
89
  catch (...)
90
    {
91
      VERIFY( false );
92
    }
93
 
94
  // imbued.
95
  ostr02.clear();
96
  ostr02.imbue(loc);
97
  try
98
    {
99
      ostream_type::sentry sentry03(ostr02);
100
      VERIFY( bool(sentry03) == true );
101
    }
102
  catch (...)
103
    {
104
      VERIFY( false );
105
    }
106
}
107
 
108
#if !__GXX_WEAK__
109
// Explicitly instantiate for systems with no COMDAT or weak support.
110
template
111
  const std::basic_string<__gnu_test::pod_ushort>::size_type
112
  std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
113
 
114
template
115
  const __gnu_test::pod_ushort
116
  std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
117
#endif
118
 
119
int main()
120
{
121
  test01();
122
  return 0;
123
}

powered by: WebSVN 2.1.0

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