diff options
Diffstat (limited to 'core/fxcrt/autorestorer_unittest.cpp')
-rw-r--r-- | core/fxcrt/autorestorer_unittest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/fxcrt/autorestorer_unittest.cpp b/core/fxcrt/autorestorer_unittest.cpp new file mode 100644 index 0000000000..ac1d613e7c --- /dev/null +++ b/core/fxcrt/autorestorer_unittest.cpp @@ -0,0 +1,23 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "core/fxcrt/autorestorer.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(fxcrt, AutoRestorer) { + int x = 5; + { + AutoRestorer<int> restorer(&x); + x = 6; + EXPECT_EQ(6, x); + } + EXPECT_EQ(5, x); + { + AutoRestorer<int> restorer(&x); + x = 6; + EXPECT_EQ(6, x); + restorer.AbandonRestoration(); + } + EXPECT_EQ(6, x); +} |