summaryrefslogtreecommitdiff
path: root/core/fxcrt/autorestorer_unittest.cpp
blob: ac1d613e7c4fe92413e8d1f90d0bcc4e9e67bb99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}