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

Function main

test/e_errno_test.cpp:22–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace leaf = boost::leaf;
21
22int main()
23{
24 errno = ENOENT;
25#if BOOST_LEAF_CFG_STD_STRING
26 std::ostringstream ss;
27 ss << leaf::e_errno{};
28 std::string s = ss.str();
29 std::cout << s << std::endl;
30#if BOOST_LEAF_CFG_STD_DIAGNOSTICS
31 BOOST_TEST_NE(s.find(std::strerror(ENOENT)), std::string::npos);
32#endif
33#endif
34
35 int r = leaf::try_handle_all(
36 []() -> leaf::result<int>
37 {
38 struct reset_errno { ~reset_errno() { errno=0; } } reset;
39 return leaf::new_error( leaf::e_errno{} );
40 },
41 []( leaf::e_errno e )
42 {
43 BOOST_TEST_EQ(errno, 0);
44 BOOST_TEST_EQ(e.value, ENOENT);
45 return 1;
46 },
47 []
48 {
49 return 2;
50 } );
51 BOOST_TEST_EQ(r, 1);
52 return boost::report_errors();
53}

Callers

nothing calls this directly

Calls 3

try_handle_allFunction · 0.85
new_errorFunction · 0.85
report_errorsFunction · 0.85

Tested by

no test coverage detected