X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fscope_guard_test.cc;fp=test%2Fscope_guard_test.cc;h=f984f50db151fed451f9d0b72afa30c3d18e86b8;hb=df20b50cc65361880d49c38d1f023f62daa9ce4b;hp=0000000000000000000000000000000000000000;hpb=fdb36750a09e3bba3d10fe5102e39a62eda68ea6;p=dcpomatic.git diff --git a/test/scope_guard_test.cc b/test/scope_guard_test.cc new file mode 100644 index 000000000..f984f50db --- /dev/null +++ b/test/scope_guard_test.cc @@ -0,0 +1,36 @@ +/* + Copyright (C) 2022 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/scope_guard.h" +#include + + +BOOST_AUTO_TEST_CASE (scope_guard_test) +{ + int x = 0; + + { + ScopeGuard sg = [&x]() { x = 42; }; + BOOST_CHECK_EQUAL (x, 0); + } + + BOOST_CHECK_EQUAL (x, 42); +}