2016-10-24 23:47:00 +00:00
|
|
|
#include "utils/scope.hpp"
|
|
|
|
|
2022-03-06 16:02:28 +00:00
|
|
|
#include "common/test.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);
|
2022-03-06 16:02:28 +00:00
|
|
|
scope_util::on_exit handler([&] { flag = true; });
|
2018-06-01 13:24:09 +00:00
|
|
|
EXPECT_FALSE(flag);
|
2016-10-24 23:47:00 +00:00
|
|
|
{
|
2022-03-06 16:02:28 +00:00
|
|
|
scope_util::on_exit handler([&] { flag = true; });
|
2016-10-24 23:47:00 +00:00
|
|
|
}
|
2018-06-01 13:24:09 +00:00
|
|
|
EXPECT_TRUE(flag);
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(flag);
|
2016-10-24 23:47:00 +00:00
|
|
|
}
|