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 | |
| 10 | // <ios> |
| 11 | |
| 12 | // class ios_base::failure |
| 13 | |
| 14 | // explicit failure(const string& msg, const error_code& ec = io_errc::stream); |
| 15 | |
| 16 | #include <ios> |
| 17 | #include <string> |
| 18 | #include <cassert> |
| 19 | |
| 20 | int main() |
| 21 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | { |
| 23 | std::string what_arg("io test message"); |
| 24 | std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory)); |
| 25 | assert(se.code() == std::make_error_code(std::errc::is_a_directory)); |
| 26 | std::string what_message(se.what()); |
| 27 | assert(what_message.find(what_arg) != std::string::npos); |
| 28 | assert(what_message.find("Is a directory") != std::string::npos); |
| 29 | } |
| 30 | { |
| 31 | std::string what_arg("io test message"); |
| 32 | std::ios_base::failure se(what_arg); |
| 33 | assert(se.code() == std::make_error_code(std::io_errc::stream)); |
| 34 | std::string what_message(se.what()); |
| 35 | assert(what_message.find(what_arg) != std::string::npos); |
| 36 | assert(what_message.find(std::iostream_category().message(static_cast<int> |
| 37 | (std::io_errc::stream))) != std::string::npos); |
| 38 | } |
| 39 | } |