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,57 +26,57 @@ namespace leaf = boost::leaf;
template <int>
struct info
{
int value;
int value;
};
void f0()
{
auto load = leaf::on_error( []( info<0> & ) { } );
throw leaf::exception(info<2>{2});
auto load = leaf::on_error( []( info<0> & ) { } );
throw leaf::exception(info<2>{2});
}
void f1()
{
auto load = leaf::on_error( info<0>{-1}, info<2>{-1}, []( info<1> & x ) {++x.value;} );
f0();
auto load = leaf::on_error( info<0>{-1}, info<2>{-1}, []( info<1> & x ) {++x.value;} );
f0();
}
void f2()
{
try
{
f1();
}
catch( leaf::error_id const & err )
{
err.load( info<3>{3} );
throw;
}
try
{
f1();
}
catch( leaf::error_id const & err )
{
err.load( info<3>{3} );
throw;
}
}
int main()
{
int r = leaf::try_catch(
[]
{
f2();
return 0;
},
[]( info<0> i0, info<1> i1, info<2> i2, info<3> i3 )
{
BOOST_TEST_EQ(i0.value, 0);
BOOST_TEST_EQ(i1.value, 1);
BOOST_TEST_EQ(i2.value, 2);
BOOST_TEST_EQ(i3.value, 3);
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
int r = leaf::try_catch(
[]
{
f2();
return 0;
},
[]( info<0> i0, info<1> i1, info<2> i2, info<3> i3 )
{
BOOST_TEST_EQ(i0.value, 0);
BOOST_TEST_EQ(i1.value, 1);
BOOST_TEST_EQ(i2.value, 2);
BOOST_TEST_EQ(i3.value, 3);
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
return boost::report_errors();
return boost::report_errors();
}
#endif