ctor_error_code_const_char_pointer.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <system_error>
11
12// class system_error
13
14// system_error(error_code ec, const char* what_arg);
15
16// Test is slightly non-portable
17
18#include <system_error>
19#include <string>
20#include <cassert>
21
22int main()
23{
24    std::string what_arg("test message");
25    std::system_error se(make_error_code(std::errc::not_a_directory), what_arg.c_str());
26    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
27    std::string what_message(se.what());
28    assert(what_message.find(what_arg) != std::string::npos);
29    assert(what_message.find("Not a directory") != std::string::npos);
30}
31