]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ostream/sentry/pod/1.cc
3 // Copyright (C) 1999-2018 Free Software Foundation, Inc.
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 3, or (at your option)
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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // 27.6.1.1.2 class basic_istream::sentry
26 #include <ext/pod_char_traits.h>
27 #include <testsuite_hooks.h>
28 #include <testsuite_character.h>
33 using __gnu_test::pod_ushort
;
34 typedef basic_string
<pod_ushort
> string_type
;
35 typedef basic_stringbuf
<pod_ushort
> stringbuf_type
;
36 typedef basic_ostream
<pod_ushort
> ostream_type
;
38 const string_type str01
;
39 stringbuf_type
* strbuf01
= 0;
40 stringbuf_type
strbuf02(str01
);
41 ostream_type
ostr01(strbuf01
);
42 ostream_type
ostr02(&strbuf02
);
47 ostream_type::sentry
sentry01(ostr01
);
49 catch (std::bad_cast
& obj
)
51 // Not ok, throws bad_cast because locale has no ctype facet,
52 // but none is needed for ostream::sentry.
61 const std::locale
loc(std::locale::classic(), new std::ctype
<pod_ushort
>);
65 ostream_type::sentry
sentry01(ostr01
);
66 VERIFY( bool(sentry01
) == false );
76 ostream_type::sentry
sentry03(ostr02
);
78 catch (std::bad_cast
& obj
)
80 // Not ok, throws bad_cast because locale has no ctype facet,
81 // but none is needed for ostream::sentry.
94 ostream_type::sentry
sentry03(ostr02
);
95 VERIFY( bool(sentry03
) == true );
104 // Explicitly instantiate for systems with no COMDAT or weak support.
106 const std::basic_string
<__gnu_test::pod_ushort
>::size_type
107 std::basic_string
<__gnu_test::pod_ushort
>::_Rep::_S_max_size
;
110 const __gnu_test::pod_ushort
111 std::basic_string
<__gnu_test::pod_ushort
>::_Rep::_S_terminal
;