Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
|
danakj
2017/03/21 20:28:55
Why is this not in base/test/ (and the test build
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ | |
| 6 #define BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ | |
| 7 | |
| 8 // This file contains some helper classes for testing conainer behavior. | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 namespace base { | |
| 13 | |
| 14 // A move-only class that holds an integer. | |
| 15 class MoveOnlyInt { | |
| 16 public: | |
| 17 explicit MoveOnlyInt(int data = 1) : data_(data) {} | |
| 18 MoveOnlyInt(MoveOnlyInt&& other) : data_(other.data_) { other.data_ = 0; } | |
| 19 MoveOnlyInt& operator=(MoveOnlyInt&& other) { | |
| 20 data_ = other.data_; | |
| 21 other.data_ = 0; | |
| 22 return *this; | |
| 23 } | |
| 24 | |
| 25 friend bool operator<(const MoveOnlyInt& lhs, const MoveOnlyInt& rhs) { | |
| 26 return lhs.data_ < rhs.data_; | |
| 27 } | |
| 28 | |
| 29 int data() const { return data_; } | |
| 30 | |
| 31 private: | |
| 32 int data_; | |
| 33 | |
| 34 DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt); | |
| 35 }; | |
| 36 | |
| 37 } // namespace base | |
| 38 | |
| 39 #endif // BASE_CONTAINERS_CONTAINER_TEST_UTILS_H_ | |
| OLD | NEW |