2018-04-07 20:16:55 +00:00
|
|
|
#include "common/test.hpp"
|
2016-10-24 23:47:00 +00:00
|
|
|
#include "utils/scope.hpp"
|
|
|
|
|
2018-06-01 13:24:09 +00:00
|
|
|
using namespace polybar;
|
2016-10-24 23:47:00 +00:00
|
|
|
|
2018-06-01 13:24:09 +00:00
|
|
|
TEST(Scope, onExit) {
|
|
|
|
auto flag = false;
|
|
|
|
{
|
|
|
|
EXPECT_FALSE(flag);
|
|
|
|
auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
|
|
|
|
EXPECT_FALSE(flag);
|
2016-10-24 23:47:00 +00:00
|
|
|
{
|
|
|
|
auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
|
|
|
|
}
|
2018-06-01 13:24:09 +00:00
|
|
|
EXPECT_TRUE(flag);
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(flag);
|
2016-10-24 23:47:00 +00:00
|
|
|
}
|