Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/template_util.h" | 5 #include "base/template_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/containers/flat_tree.h" | |
| 10 #include "base/test/move_only_int.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 namespace base { | 13 namespace base { |
| 12 namespace { | 14 namespace { |
| 13 | 15 |
| 14 enum SimpleEnum { SIMPLE_ENUM }; | 16 enum SimpleEnum { SIMPLE_ENUM }; |
| 15 enum EnumWithExplicitType : uint64_t { ENUM_WITH_EXPLICIT_TYPE }; | 17 enum EnumWithExplicitType : uint64_t { ENUM_WITH_EXPLICIT_TYPE }; |
| 16 enum class ScopedEnum { SCOPED_ENUM }; | 18 enum class ScopedEnum { SCOPED_ENUM }; |
| 17 enum class ScopedEnumWithOperator { SCOPED_ENUM_WITH_OPERATOR }; | 19 enum class ScopedEnumWithOperator { SCOPED_ENUM_WITH_OPERATOR }; |
| 18 std::ostream& operator<<(std::ostream& os, ScopedEnumWithOperator v) { | 20 std::ostream& operator<<(std::ostream& os, ScopedEnumWithOperator v) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 "simple struct should not be printable by value"); | 65 "simple struct should not be printable by value"); |
| 64 static_assert(!internal::SupportsOstreamOperator<const SimpleStruct&>::value, | 66 static_assert(!internal::SupportsOstreamOperator<const SimpleStruct&>::value, |
| 65 "simple struct should not be printable by const ref"); | 67 "simple struct should not be printable by const ref"); |
| 66 static_assert(internal::SupportsOstreamOperator<StructWithOperator>::value, | 68 static_assert(internal::SupportsOstreamOperator<StructWithOperator>::value, |
| 67 "struct with operator<< should be printable by value"); | 69 "struct with operator<< should be printable by value"); |
| 68 static_assert( | 70 static_assert( |
| 69 internal::SupportsOstreamOperator<const StructWithOperator&>::value, | 71 internal::SupportsOstreamOperator<const StructWithOperator&>::value, |
| 70 "struct with operator<< should be printable by const ref"); | 72 "struct with operator<< should be printable by const ref"); |
| 71 | 73 |
| 72 } // namespace | 74 } // namespace |
| 75 | |
| 76 TEST(Functors, Less) { | |
|
danakj
2017/06/27 23:48:25
nit: TemplateUtil.Less would be easier to find
dyaroshev
2017/06/28 09:13:59
Done.
| |
| 77 using ExplicitInt = base::MoveOnlyInt; | |
| 78 EXPECT_TRUE(base::less()(ExplicitInt(3), 4)); | |
| 79 EXPECT_FALSE(base::less()(4, ExplicitInt(3))); | |
| 80 EXPECT_TRUE(base::less()(3, 4)); | |
| 81 | |
| 82 static_assert(base::internal::IsTransparentCompare<base::less>::value, ""); | |
| 83 } | |
| 84 | |
| 73 } // namespace base | 85 } // namespace base |
| OLD | NEW |