mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
31
libs/base/base_tests/scope_guard_test.cpp
Normal file
31
libs/base/base_tests/scope_guard_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "base/scope_guard.hpp"
|
||||
|
||||
static bool b = false;
|
||||
|
||||
void SetB()
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
|
||||
UNIT_TEST(ScopeGuard)
|
||||
{
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
}
|
||||
TEST_EQUAL(b, true, ("scope_guard works in destructor"));
|
||||
}
|
||||
|
||||
UNIT_TEST(ScopeGuardRelease)
|
||||
{
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
guard.release();
|
||||
}
|
||||
TEST_EQUAL(b, false, ("If relese() was called then scope_guard shouldn't work"));
|
||||
}
|
||||
Reference in New Issue
Block a user