Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: base/test/move_only_int.h

Issue 2898213003: Add skeleton circular queue file.
Patch Set: Fix merge 2 Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/copy_only_int.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ 5 #ifndef BASE_TEST_MOVE_ONLY_INT_H_
6 #define BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ 6 #define BASE_TEST_MOVE_ONLY_INT_H_
7
8 // This file contains some helper classes for testing conainer behavior.
9 7
10 #include "base/macros.h" 8 #include "base/macros.h"
11 9
12 namespace base { 10 namespace base {
13 11
14 // A move-only class that holds an integer. 12 // A move-only class that holds an integer. This is designed for testing
13 // containers. See also CopyOnlyInt.
15 class MoveOnlyInt { 14 class MoveOnlyInt {
16 public: 15 public:
17 explicit MoveOnlyInt(int data = 1) : data_(data) {} 16 explicit MoveOnlyInt(int data = 1) : data_(data) {}
18 MoveOnlyInt(MoveOnlyInt&& other) : data_(other.data_) { other.data_ = 0; } 17 MoveOnlyInt(MoveOnlyInt&& other) : data_(other.data_) { other.data_ = 0; }
18 ~MoveOnlyInt() { data_ = 0; }
19
19 MoveOnlyInt& operator=(MoveOnlyInt&& other) { 20 MoveOnlyInt& operator=(MoveOnlyInt&& other) {
20 data_ = other.data_; 21 data_ = other.data_;
21 other.data_ = 0; 22 other.data_ = 0;
22 return *this; 23 return *this;
23 } 24 }
24 25
25 friend bool operator==(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) { 26 friend bool operator==(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
26 return lhs.data_ == rhs.data_; 27 return lhs.data_ == rhs.data_;
27 } 28 }
28 29
(...skipping 28 matching lines...) Expand all
57 int data() const { return data_; } 58 int data() const { return data_; }
58 59
59 private: 60 private:
60 int data_; 61 int data_;
61 62
62 DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt); 63 DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt);
63 }; 64 };
64 65
65 } // namespace base 66 } // namespace base
66 67
67 #endif // BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ 68 #endif // BASE_TEST_MOVE_ONLY_INT_H_
OLDNEW
« no previous file with comments | « base/test/copy_only_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698