Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 27_io / basic_ostream / sentry / pod / 1.cc
blob7cad09fa695babb6a9fff6e12aff49d3b8a9cac3
1 // 1999-10-14 bkoz
3 // Copyright (C) 1999, 2001, 2003, 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // 27.6.1.1.2 class basic_istream::sentry
32 #include <ostream>
33 #include <sstream>
34 #include <ext/pod_char_traits.h>
35 #include <testsuite_hooks.h>
36 #include <testsuite_character.h>
38 void test01()
40 using namespace std;
41 using __gnu_test::pod_ushort;
42 typedef basic_string<pod_ushort> string_type;
43 typedef basic_stringbuf<pod_ushort> stringbuf_type;
44 typedef basic_ostream<pod_ushort> ostream_type;
46 bool test __attribute__((unused)) = true;
49 const string_type str01;
50 stringbuf_type* strbuf01 = NULL;
51 stringbuf_type strbuf02(str01);
52 ostream_type ostr01(strbuf01);
53 ostream_type ostr02(&strbuf02);
55 // test negatives
56 try
58 ostream_type::sentry sentry01(ostr01);
60 catch (std::bad_cast& obj)
62 // Not ok, throws bad_cast because locale has no ctype facet,
63 // but none is needed for ostream::sentry.
64 VERIFY( false );
66 catch (...)
68 VERIFY( false );
71 // imbued.
72 const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
73 ostr01.imbue(loc);
74 try
76 ostream_type::sentry sentry01(ostr01);
77 VERIFY( bool(sentry01) == false );
79 catch (...)
81 VERIFY( false );
84 // test positive
85 try
87 ostream_type::sentry sentry03(ostr02);
89 catch (std::bad_cast& obj)
91 // Not ok, throws bad_cast because locale has no ctype facet,
92 // but none is needed for ostream::sentry.
93 VERIFY( false );
95 catch (...)
97 VERIFY( false );
100 // imbued.
101 ostr02.clear();
102 ostr02.imbue(loc);
105 ostream_type::sentry sentry03(ostr02);
106 VERIFY( bool(sentry03) == true );
108 catch (...)
110 VERIFY( false );
114 #if !__GXX_WEAK__
115 // Explicitly instantiate for systems with no COMDAT or weak support.
116 template
117 std::basic_string<__gnu_test::pod_ushort>::size_type
118 std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
120 template
121 __gnu_test::pod_ushort
122 std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
123 #endif
125 int main()
127 test01();
128 return 0;