1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <system_error> |
10 | |
11 | // class system_error |
12 | |
13 | // system_error(error_code ec, const string& what_arg); |
14 | |
15 | // Test is slightly non-portable |
16 | |
17 | #include <system_error> |
18 | #include <string> |
19 | #include <cassert> |
20 | |
21 | #include "test_macros.h" |
22 | |
23 | int main(int, char**) { |
24 | std::string what_arg("test message"); |
25 | std::system_error se(make_error_code(e: std::errc::not_a_directory), what_arg); |
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 | return 0; |
32 | } |
33 |