blob: 5c9abbe53793ef8790390c920fab7b4b6ee1f953 [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
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
20int main()
21{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022 {
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}