1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/tests/utils/test_scope.cpp

31 lines
718 B
C++
Raw Normal View History

2016-06-14 23:32:35 -04:00
#include <iomanip>
#include <lemonbuddy/utils/scope.hpp>
#include "../unit_test.hpp"
using namespace lemonbuddy;
class test_scope : public unit_test {
public:
CPPUNIT_TEST_SUITE(test_scope);
CPPUNIT_TEST(test_on_exit);
CPPUNIT_TEST_SUITE_END();
void test_on_exit() {
auto flag = false;
{
CPPUNIT_ASSERT_EQUAL(false, flag);
auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
CPPUNIT_ASSERT_EQUAL(false, flag);
{
auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
}
CPPUNIT_ASSERT_EQUAL(true, flag);
flag = false;
}
CPPUNIT_ASSERT_EQUAL(true, flag);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(test_scope);