polybar-dwm/tests/unit_tests/utils/scope.cpp

20 lines
406 B
C++
Raw Normal View History

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