diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-27 21:14:22 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-27 21:14:22 +0000 |
commit | a2c2a9d2a1e718e08bb90f92a2f24f4cb990189f (patch) | |
tree | 79b96a806474543b292a3b6b3df9d8fcc74b8a50 /core/fxcrt/autorestorer_unittest.cpp | |
parent | 3ab8fa91422e8ce6874f9a89a61cb043858ad8b5 (diff) | |
download | pdfium-a2c2a9d2a1e718e08bb90f92a2f24f4cb990189f.tar.xz |
Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475
Kinda like reaching a commit point, makes going forward more useful.
Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c
Reviewed-on: https://pdfium-review.googlesource.com/35970
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
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); +} |