blob: a0013eabdac636b0fc127db9a0799973d4fa4d0c [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000010// <ios>
11
12// template <class charT, class traits> class basic_ios
13
14// iostate exceptions() const;
15
16#include <ios>
17#include <streambuf>
18#include <cassert>
19
20struct testbuf : public std::streambuf {};
21
22int main()
23{
24 {
25 std::ios ios(0);
26 assert(ios.exceptions() == std::ios::goodbit);
27 ios.exceptions(std::ios::eofbit);
28 assert(ios.exceptions() == std::ios::eofbit);
29 try
30 {
31 ios.exceptions(std::ios::badbit);
32 assert(false);
33 }
34 catch (std::ios::failure&)
35 {
36 }
37 assert(ios.exceptions() == std::ios::badbit);
38 }
39 {
40 testbuf sb;
41 std::ios ios(&sb);
42 assert(ios.exceptions() == std::ios::goodbit);
43 ios.exceptions(std::ios::eofbit);
44 assert(ios.exceptions() == std::ios::eofbit);
45 ios.exceptions(std::ios::badbit);
46 assert(ios.exceptions() == std::ios::badbit);
47 }
48}