aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.util/guard.test.cc
blob: 2c3ac2f698fbaef891b0f6528594da94daa0af2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// This source code is released into the public domain.

#include <catch2/catch_test_macros.hpp>

import nihil.util;

TEST_CASE("guard: basic", "[guard]") {
	int n = 0;

	{
		auto guard = nihil::guard([&] { n = 1; });
		REQUIRE(n == 0);
	}

	REQUIRE(n == 1);
}