1//
2// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// Official repository: https://github.com/boostorg/beast
8//
9
10// Test that header file is self-contained.
11#include <boost/beast/core/error.hpp>
12
13#include <boost/beast/_experimental/unit_test/suite.hpp>
14#include <memory>
15
16namespace boost {
17namespace beast {
18
19class error_test : public unit_test::suite
20{
21public:
22 // no condition
23 void check(error e)
24 {
25 auto const ec = make_error_code(e);
26 ec.category().name();
27 BEAST_EXPECT(! ec.message().empty());
28 }
29
30 void check(condition c, error e)
31 {
32 {
33 auto const ec = make_error_code(e);
34 BEAST_EXPECT(ec.category().name() != nullptr);
35 BEAST_EXPECT(! ec.message().empty());
36 BEAST_EXPECT(ec == c);
37 BEAST_EXPECT(ec.message(nullptr, 0) != nullptr);
38 }
39 {
40 auto ec = make_error_condition(c);
41 BEAST_EXPECT(ec.category().name() != nullptr);
42 BEAST_EXPECT(! ec.message().empty());
43 BEAST_EXPECT(ec == c);
44 BEAST_EXPECT(ec.message(nullptr, 0) != nullptr);
45 }
46 }
47
48 void run() override
49 {
50 check(c: condition::timeout, e: error::timeout);
51 }
52};
53
54BEAST_DEFINE_TESTSUITE(beast,core,error);
55
56} // beast
57} // boost
58

source code of boost/libs/beast/test/beast/core/error.cpp