ScopeGuardTest.cpp 657 B

12345678910111213141516171819202122232425262728
  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. #include <gtest/gtest.h>
  11. using namespace pzstd;
  12. TEST(ScopeGuard, Dismiss) {
  13. {
  14. auto guard = makeScopeGuard([&] { EXPECT_TRUE(false); });
  15. guard.dismiss();
  16. }
  17. }
  18. TEST(ScopeGuard, Executes) {
  19. bool executed = false;
  20. {
  21. auto guard = makeScopeGuard([&] { executed = true; });
  22. }
  23. EXPECT_TRUE(executed);
  24. }