2017-08-31 11:24:54 -07:00
|
|
|
/*
|
2022-12-20 12:49:47 -05:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-09-01 15:22:19 -07:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-08-31 11:24:54 -07:00
|
|
|
* This source code is licensed under both the BSD-style license (found in the
|
|
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
* in the COPYING file in the root directory of this source tree).
|
2016-09-01 15:22:19 -07:00
|
|
|
*/
|
|
|
|
#include "utils/ScopeGuard.h"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
using namespace pzstd;
|
|
|
|
|
|
|
|
TEST(ScopeGuard, Dismiss) {
|
|
|
|
{
|
|
|
|
auto guard = makeScopeGuard([&] { EXPECT_TRUE(false); });
|
|
|
|
guard.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ScopeGuard, Executes) {
|
|
|
|
bool executed = false;
|
|
|
|
{
|
|
|
|
auto guard = makeScopeGuard([&] { executed = true; });
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(executed);
|
|
|
|
}
|