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

Function test

test/handle_some_other_result_test.cpp:52–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51template <class ResType>
52void test()
53{
54 {
55 ResType r = leaf::try_handle_some(
56 []
57 {
58 return g<ResType>(true);
59 } );
60 BOOST_TEST(r);
61 BOOST_TEST_EQ(r.value(), 42);
62 }
63 {
64 int called = 0;
65 ResType r = leaf::try_handle_some(
66 [&]
67 {
68 auto r1 = g<ResType>(false);
69 BOOST_TEST(!r1);
70 auto ec = r1.error();
71 BOOST_TEST_EQ(ec.message(), "LEAF error");
72 BOOST_TEST(!std::strcmp(ec.category().name(),"LEAF error"));
73 return r1;
74 },
75 [&]( info<42> const & x, leaf::match<leaf::condition<cond_x>, cond_x::x00> ec )
76 {
77 called = 1;
78 BOOST_TEST_EQ(x.value, 42);
79 return ec.matched;
80 } );
81 BOOST_TEST(!r);
82 BOOST_TEST_EQ(r.error(), make_error_code(errc_a::a0));
83 BOOST_TEST(called);
84 }
85}
86
87int main()
88{

Callers

nothing calls this directly

Calls 5

try_handle_someFunction · 0.85
make_error_codeFunction · 0.70
valueMethod · 0.45
messageMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected