aboutsummaryrefslogtreecommitdiffstats
path: root/tests/guard.cc
blob: f88aa9b4087d1969c8cebdf29c62f2e44f06f91b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * This source code is released into the public domain.
 */

#include <catch2/catch_test_macros.hpp>

import nihil;

using namespace std::literals;

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

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

	REQUIRE(n == 1);
}