MCPcopy Create free account
hub / github.com/boostorg/leaf / test

Function test

test/error_code_test.cpp:41–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template <class R>
41void test()
42{
43#if __cplusplus >= 201703L
44 {
45 int r = leaf::try_handle_all(
46 []() -> R
47 {
48 return make_error_code(errc_a::a0);
49 },
50 []( leaf::match<std::error_code, leaf::category<errc_a>, leaf::category<errc_b>> code )
51 {
52 std::error_code const & ec = code.matched;
53 BOOST_TEST_EQ(&ec.category(), &cat_errc_a());
54 BOOST_TEST_EQ(ec, errc_a::a0);
55 return 42;
56 },
57 []
58 {
59 return -42;
60 } );
61 BOOST_TEST_EQ(r, 42);
62 }
63 {
64 int r = leaf::try_handle_all(
65 []() -> R
66 {
67 return make_error_code(errc_b::b0);
68 },
69 []( leaf::match<std::error_code, leaf::category<errc_a>, leaf::category<errc_b>> code )
70 {
71 std::error_code const & ec = code.matched;
72 BOOST_TEST_EQ(&ec.category(), &cat_errc_b());
73 BOOST_TEST_EQ(ec, errc_b::b0);
74 return 42;
75 },
76 []
77 {
78 return -42;
79 } );
80 BOOST_TEST_EQ(r, 42);
81 }
82 {
83 int r = leaf::try_handle_all(
84 []() -> R
85 {
86 return make_error_code(errc_b::b0);
87 },
88 []( leaf::match<std::error_code, leaf::category<errc_a>, errc_b::b0> code )
89 {
90 std::error_code const & ec = code.matched;
91 BOOST_TEST_EQ(&ec.category(), &cat_errc_b());
92 BOOST_TEST_EQ(ec, errc_b::b0);
93 return 42;
94 },
95 []
96 {
97 return -42;
98 } );

Callers

nothing calls this directly

Calls 5

try_handle_allFunction · 0.85
is_error_idFunction · 0.85
make_error_conditionFunction · 0.85
new_errorFunction · 0.85
make_error_codeFunction · 0.70

Tested by

no test coverage detected