OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "Test.h" | 7 #include "Test.h" |
8 #include "SkTemplates.h" | 8 #include "SkTemplates.h" |
| 9 #include "SkScopeExit.h" |
9 #include <utility> | 10 #include <utility> |
10 | 11 |
11 namespace { | 12 namespace { |
12 class Moveable { | 13 class Moveable { |
13 public: | 14 public: |
14 Moveable() {} | 15 Moveable() {} |
15 Moveable(Moveable&&) {} | 16 Moveable(Moveable&&) {} |
16 Moveable& operator=(Moveable&&) { return *this; } | 17 Moveable& operator=(Moveable&&) { return *this; } |
17 private: | 18 private: |
18 Moveable(const Moveable&); | 19 Moveable(const Moveable&); |
(...skipping 29 matching lines...) Expand all Loading... |
48 }; | 49 }; |
49 } // namespace | 50 } // namespace |
50 | 51 |
51 DEF_TEST(CPlusPlusEleven_default_move, r) { | 52 DEF_TEST(CPlusPlusEleven_default_move, r) { |
52 TestClass a; | 53 TestClass a; |
53 TestClass b(a); | 54 TestClass b(a); |
54 TestClass c(std::move(a)); | 55 TestClass c(std::move(a)); |
55 REPORTER_ASSERT(r, b.fFoo.fCopied); | 56 REPORTER_ASSERT(r, b.fFoo.fCopied); |
56 REPORTER_ASSERT(r, !c.fFoo.fCopied); | 57 REPORTER_ASSERT(r, !c.fFoo.fCopied); |
57 } | 58 } |
| 59 |
| 60 DEF_TEST(SkAtScopeExit, r) { |
| 61 int x = 5; |
| 62 { |
| 63 SK_AT_SCOPE_EXIT(x--); |
| 64 REPORTER_ASSERT(r, x == 5); |
| 65 } |
| 66 REPORTER_ASSERT(r, x == 4); |
| 67 } |
OLD | NEW |