fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / base / auto_reset_unittest.cc
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/auto_reset.h"
6
7 #include <utility>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12
13 TEST(AutoReset, Move) {
14   int value = 10;
15   {
16     AutoReset<int> resetter1{&value, 20};
17     EXPECT_EQ(20, value);
18     {
19       value = 15;
20       AutoReset<int> resetter2 = std::move(resetter1);
21       // Moving to a new resetter does not change the value;
22       EXPECT_EQ(15, value);
23     }
24     // Moved-to `resetter2` is out of scoped, and resets to the original value
25     // that was in moved-from `resetter1`.
26     EXPECT_EQ(10, value);
27     value = 105;
28   }
29   // Moved-from `resetter1` does not reset to anything.
30   EXPECT_EQ(105, value);
31 }
32
33 }  // namespace base