Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Asiri Rathnayake | cc2e93c | 2015-11-10 11:41:22 +0000 | [diff] [blame] | 10 | // XFAIL: libcpp-no-exceptions |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 11 | // <ios> |
| 12 | |
| 13 | // template <class charT, class traits> class basic_ios |
| 14 | |
| 15 | // void clear(iostate state = goodbit); |
| 16 | |
| 17 | #include <ios> |
| 18 | #include <streambuf> |
| 19 | #include <cassert> |
| 20 | |
| 21 | struct testbuf : public std::streambuf {}; |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | { |
| 26 | std::ios ios(0); |
| 27 | ios.clear(); |
| 28 | assert(ios.rdstate() == std::ios::badbit); |
| 29 | try |
| 30 | { |
| 31 | ios.exceptions(std::ios::badbit); |
| 32 | } |
| 33 | catch (...) |
| 34 | { |
| 35 | } |
| 36 | try |
| 37 | { |
| 38 | ios.clear(); |
| 39 | assert(false); |
| 40 | } |
| 41 | catch (std::ios::failure&) |
| 42 | { |
| 43 | assert(ios.rdstate() == std::ios::badbit); |
| 44 | } |
| 45 | try |
| 46 | { |
| 47 | ios.clear(std::ios::eofbit); |
| 48 | assert(false); |
| 49 | } |
| 50 | catch (std::ios::failure&) |
| 51 | { |
| 52 | assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); |
| 53 | } |
| 54 | } |
| 55 | { |
| 56 | testbuf sb; |
| 57 | std::ios ios(&sb); |
| 58 | ios.clear(); |
| 59 | assert(ios.rdstate() == std::ios::goodbit); |
| 60 | ios.exceptions(std::ios::badbit); |
| 61 | ios.clear(); |
| 62 | assert(ios.rdstate() == std::ios::goodbit); |
| 63 | ios.clear(std::ios::eofbit); |
| 64 | assert(ios.rdstate() == std::ios::eofbit); |
| 65 | } |
| 66 | } |