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

Side by Side Diff: base/template_util_unittest.cc

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Other platforms compilation 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/template_util.h ('k') | base/test/move_only_int.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 (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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ~TrivialCopyButWithDestructor() { data_ = 0; } 86 ~TrivialCopyButWithDestructor() { data_ = 0; }
85 }; 87 };
86 88
87 static_assert(base::is_trivially_copyable<TrivialCopy>::value, 89 static_assert(base::is_trivially_copyable<TrivialCopy>::value,
88 "TrivialCopy should be detected as trivially copyable"); 90 "TrivialCopy should be detected as trivially copyable");
89 static_assert(!base::is_trivially_copyable<TrivialCopyButWithDestructor>::value, 91 static_assert(!base::is_trivially_copyable<TrivialCopyButWithDestructor>::value,
90 "TrivialCopyButWithDestructor should not be detected as " 92 "TrivialCopyButWithDestructor should not be detected as "
91 "trivially copyable"); 93 "trivially copyable");
92 94
93 } // namespace 95 } // namespace
96
97 TEST(TemplateUtil, Less) {
98 using ExplicitInt = base::MoveOnlyInt;
99 EXPECT_TRUE(base::less()(ExplicitInt(3), 4));
100 EXPECT_FALSE(base::less()(4, ExplicitInt(3)));
101 EXPECT_TRUE(base::less()(3, 4));
102
103 static_assert(base::internal::IsTransparentCompare<base::less>::value, "");
104 }
105
94 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/template_util.h ('k') | base/test/move_only_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698