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

Side by Side Diff: base/containers/container_test_utils.h

Issue 2807933002: Removing (dest != prev) check from LastUnique algorithm. (Closed)
Patch Set: Comments 2. Created 3 years, 7 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 | « no previous file | base/containers/flat_tree.h » ('j') | 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_CONTAINERS_CONTAINER_TEST_UTILS_H_
6 #define BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ 6 #define BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_
7 7
8 // This file contains some helper classes for testing conainer behavior. 8 // This file contains some helper classes for testing conainer behavior.
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 // A move-only class that holds an integer. 14 // A move-only class that holds an integer.
15 class MoveOnlyInt { 15 class MoveOnlyInt {
16 public: 16 public:
17 explicit MoveOnlyInt(int data = 1) : data_(data) {} 17 explicit MoveOnlyInt(int data = 1) : data_(data) {}
18 MoveOnlyInt(MoveOnlyInt&& other) : data_(other.data_) { other.data_ = 0; } 18 MoveOnlyInt(MoveOnlyInt&& other) : data_(other.data_) { other.data_ = 0; }
19 MoveOnlyInt& operator=(MoveOnlyInt&& other) { 19 MoveOnlyInt& operator=(MoveOnlyInt&& other) {
20 data_ = other.data_; 20 data_ = other.data_;
21 other.data_ = 0; 21 other.data_ = 0;
22 return *this; 22 return *this;
23 } 23 }
24 24
25 friend bool operator==(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
26 return lhs.data_ == rhs.data_;
27 }
28
29 friend bool operator!=(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
30 return !operator==(lhs, rhs);
31 }
32
25 friend bool operator<(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) { 33 friend bool operator<(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
26 return lhs.data_ < rhs.data_; 34 return lhs.data_ < rhs.data_;
27 } 35 }
28 36
37 friend bool operator>(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
38 return rhs < lhs;
39 }
40
41 friend bool operator<=(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
42 return !(rhs < lhs);
43 }
44
45 friend bool operator>=(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) {
46 return !(lhs < rhs);
47 }
48
29 int data() const { return data_; } 49 int data() const { return data_; }
30 50
31 private: 51 private:
32 int data_; 52 int data_;
33 53
34 DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt); 54 DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt);
35 }; 55 };
36 56
37 } // namespace base 57 } // namespace base
38 58
39 #endif // BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ 59 #endif // BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | base/containers/flat_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698