Added test that Final_act object can be moved properly. While this is not a common case, it may happen if the user calls finally and the compiler fails to perform RVO.
This commit is contained in:
1 parent
1d11cd1ed1
commit
ae24c0fe06
1 file changed
+14
@@ -37,6 +37,20 @@ SUITE(utils_tests)
|
||||
CHECK(i == 1);
|
||||
}
|
||||
|
||||
TEST(finally_lambda_move)
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
auto _1 = finally([&]() {f(i);});
|
||||
{
|
||||
auto _2 = std::move(_1);
|
||||
CHECK(i == 0);
|
||||
}
|
||||
CHECK(i == 1);
|
||||
}
|
||||
CHECK(i == 1);
|
||||
}
|
||||
|
||||
TEST(finally_function_with_bind)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
Reference in new issue
Block a user