2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
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)
7 // Official repository: https://github.com/boostorg/json
10 // Test that header file is self-contained.
11 #include <boost/json/error.hpp>
15 #include "test_suite.hpp"
24 auto const ec
= make_error_code(e
);
25 BOOST_TEST(ec
.category().name() != nullptr);
26 BOOST_TEST(! ec
.message().empty());
27 BOOST_TEST(ec
.category().default_error_condition(
28 static_cast<int>(e
)).category() == ec
.category());
31 void check(condition c
, error e
)
34 auto const ec
= make_error_code(e
);
35 BOOST_TEST(ec
.category().name() != nullptr);
36 BOOST_TEST(! ec
.message().empty());
40 auto ec
= make_error_condition(c
);
41 BOOST_TEST(ec
.category().name() != nullptr);
42 BOOST_TEST(! ec
.message().empty());
50 check(condition::parse_error
, error::syntax
);
51 check(condition::parse_error
, error::extra_data
);
52 check(condition::parse_error
, error::incomplete
);
53 check(condition::parse_error
, error::exponent_overflow
);
54 check(condition::parse_error
, error::too_deep
);
55 check(condition::parse_error
, error::illegal_leading_surrogate
);
56 check(condition::parse_error
, error::illegal_trailing_surrogate
);
57 check(condition::parse_error
, error::expected_hex_digit
);
58 check(condition::parse_error
, error::expected_utf16_escape
);
59 check(condition::parse_error
, error::object_too_large
);
60 check(condition::parse_error
, error::array_too_large
);
61 check(condition::parse_error
, error::key_too_large
);
62 check(condition::parse_error
, error::string_too_large
);
63 check(condition::parse_error
, error::exception
);
65 check(condition::assign_error
, error::not_number
);
66 check(condition::assign_error
, error::not_exact
);
68 check(condition::pointer_parse_error
, error::missing_slash
);
69 check(condition::pointer_parse_error
, error::invalid_escape
);
71 check(condition::pointer_use_error
, error::token_not_number
);
72 check(condition::pointer_use_error
, error::value_is_scalar
);
73 check(condition::pointer_use_error
, error::not_found
);
74 check(condition::pointer_use_error
, error::token_overflow
);
75 check(condition::pointer_use_error
, error::past_the_end
);
77 check(error::test_failure
);
80 std::error_code
const ec
= error::syntax
;
81 BOOST_TEST(ec
== error::syntax
);
82 BOOST_TEST(ec
== condition::parse_error
);
86 TEST_SUITE(error_test
, "boost.json.error");