1 /* 2 * Copyright (c) 2016-present, Facebook, Inc. 3 * All rights reserved. 4 * 5 * This source code is licensed under both the BSD-style license (found in the 6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 * in the COPYING file in the root directory of this source tree). 8 */ 9 #include "utils/ScopeGuard.h" 10 11 #include <gtest/gtest.h> 12 13 using namespace pzstd; 14 TEST(ScopeGuard,Dismiss)15TEST(ScopeGuard, Dismiss) { 16 { 17 auto guard = makeScopeGuard([&] { EXPECT_TRUE(false); }); 18 guard.dismiss(); 19 } 20 } 21 TEST(ScopeGuard,Executes)22TEST(ScopeGuard, Executes) { 23 bool executed = false; 24 { 25 auto guard = makeScopeGuard([&] { executed = true; }); 26 } 27 EXPECT_TRUE(executed); 28 } 29