]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ostream/sentry/pod/1.cc
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 // Free Software Foundation, Inc.
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)
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.
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/>.
23 // 27.6.1.1.2 class basic_istream::sentry
28 #include <ext/pod_char_traits.h>
29 #include <testsuite_hooks.h>
30 #include <testsuite_character.h>
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
;
40 bool test
__attribute__((unused
)) = true;
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
);
52 ostream_type::sentry
sentry01(ostr01
);
54 catch (std::bad_cast
& obj
)
56 // Not ok, throws bad_cast because locale has no ctype facet,
57 // but none is needed for ostream::sentry.
66 const std::locale
loc(std::locale::classic(), new std::ctype
<pod_ushort
>);
70 ostream_type::sentry
sentry01(ostr01
);
71 VERIFY( bool(sentry01
) == false );
81 ostream_type::sentry
sentry03(ostr02
);
83 catch (std::bad_cast
& obj
)
85 // Not ok, throws bad_cast because locale has no ctype facet,
86 // but none is needed for ostream::sentry.
99 ostream_type::sentry
sentry03(ostr02
);
100 VERIFY( bool(sentry03
) == true );
109 // Explicitly instantiate for systems with no COMDAT or weak support.
111 const std::basic_string
<__gnu_test::pod_ushort
>::size_type
112 std::basic_string
<__gnu_test::pod_ushort
>::_Rep::_S_max_size
;
115 const __gnu_test::pod_ushort
116 std::basic_string
<__gnu_test::pod_ushort
>::_Rep::_S_terminal
;