2
0
mirror of https://github.com/boostorg/leaf.git synced 2026-01-31 20:22:15 +00:00
This commit is contained in:
Emil Dotchevski
2020-10-20 12:23:13 -07:00
parent c20262d1f8
commit 44eec77cf0
103 changed files with 15900 additions and 15900 deletions

View File

@@ -10,8 +10,8 @@
int main()
{
std::cout << "Unit test not applicable." << std::endl;
return 0;
std::cout << "Unit test not applicable." << std::endl;
return 0;
}
#else
@@ -26,122 +26,122 @@ namespace leaf = boost::leaf;
template <int>
struct info
{
int value;
int value;
};
template <class Thrower>
void g1( Thrower th )
{
auto load = leaf::on_error( info<1>{} );
th();
auto load = leaf::on_error( info<1>{} );
th();
}
template <class Thrower>
void g2( Thrower th )
{
auto load = leaf::on_error(info<3>{}, info<2>{} );
th();
auto load = leaf::on_error(info<3>{}, info<2>{} );
th();
}
template <class Thrower>
void f1( Thrower th )
{
return g1(th);
return g1(th);
}
template <class Thrower>
void f2( Thrower th )
{
return g2(th);
return g2(th);
}
int main()
{
BOOST_TEST_EQ(1,
leaf::try_catch(
[]
{
f1( [] { throw leaf::exception(); } );
return 0;
},
[]( leaf::error_info const & err, info<1> )
{
BOOST_TEST_EQ(err.error().value(), 1);
return 1;
},
[]( info<2> )
{
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
BOOST_TEST_EQ(1,
leaf::try_catch(
[]
{
f1( [] { throw leaf::exception(); } );
return 0;
},
[]( leaf::error_info const & err, info<1> )
{
BOOST_TEST_EQ(err.error().value(), 1);
return 1;
},
[]( info<2> )
{
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
BOOST_TEST_EQ(2,
leaf::try_catch(
[]
{
f2( [] { throw leaf::exception(); } );
return 0;
},
[]( info<1> )
{
return 1;
},
[]( leaf::error_info const & err, info<2>, info<3> )
{
BOOST_TEST_EQ(err.error().value(), 9);
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
BOOST_TEST_EQ(2,
leaf::try_catch(
[]
{
f2( [] { throw leaf::exception(); } );
return 0;
},
[]( info<1> )
{
return 1;
},
[]( leaf::error_info const & err, info<2>, info<3> )
{
BOOST_TEST_EQ(err.error().value(), 9);
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
BOOST_TEST_EQ(1,
leaf::try_catch(
[]
{
f1( [] { throw std::exception(); } );
return 0;
},
[]( leaf::error_info const & err, info<1> )
{
BOOST_TEST_EQ(err.error().value(), 17);
return 1;
},
[]( info<2> )
{
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ) );
BOOST_TEST_EQ(1,
leaf::try_catch(
[]
{
f1( [] { throw std::exception(); } );
return 0;
},
[]( leaf::error_info const & err, info<1> )
{
BOOST_TEST_EQ(err.error().value(), 17);
return 1;
},
[]( info<2> )
{
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ) );
BOOST_TEST_EQ(2,
leaf::try_catch(
[]
{
f2( [] { throw std::exception(); } );
return 0;
},
[]( info<1> )
{
return 1;
},
[]( leaf::error_info const & err, info<2>, info<3> )
{
BOOST_TEST_EQ(err.error().value(), 21);
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
BOOST_TEST_EQ(2,
leaf::try_catch(
[]
{
f2( [] { throw std::exception(); } );
return 0;
},
[]( info<1> )
{
return 1;
},
[]( leaf::error_info const & err, info<2>, info<3> )
{
BOOST_TEST_EQ(err.error().value(), 21);
return 2;
},
[]( info<1>, info<2> )
{
return 3;
} ));
return boost::report_errors();
return boost::report_errors();
}
#endif