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

21 lines
369 B
C++
Raw Permalink Normal View History

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