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

Side by Side Diff: base/tuple_unittest.cc

Issue 2797133002: Replace base::get with std::get (Closed)
Patch Set: +styleguide Created 3 years, 8 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/tuple.h ('k') | styleguide/c++/c++11.html » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/tuple.h" 5 #include "base/tuple.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 EXPECT_EQ(1, CopyLogger::TimesCopied); 107 EXPECT_EQ(1, CopyLogger::TimesCopied);
108 108
109 // Now they should be different, since the function call will make a copy. 109 // Now they should be different, since the function call will make a copy.
110 res = false; 110 res = false;
111 DispatchToFunction(&SomeLoggerMethCopy, tuple); 111 DispatchToFunction(&SomeLoggerMethCopy, tuple);
112 EXPECT_FALSE(res); 112 EXPECT_FALSE(res);
113 EXPECT_EQ(3, CopyLogger::TimesConstructed); 113 EXPECT_EQ(3, CopyLogger::TimesConstructed);
114 EXPECT_EQ(2, CopyLogger::TimesCopied); 114 EXPECT_EQ(2, CopyLogger::TimesCopied);
115 } 115 }
116 116
117 TEST(TupleTest, Get) {
118 int i = 1;
119 int j = 2;
120 std::tuple<int, int&, int&&> t(3, i, std::move(j));
121 EXPECT_TRUE((std::is_same<int&, decltype(base::get<0>(t))>::value));
122 EXPECT_EQ(3, base::get<0>(t));
123
124 EXPECT_TRUE((std::is_same<int&, decltype(base::get<1>(t))>::value));
125 EXPECT_EQ(1, base::get<1>(t));
126
127 EXPECT_TRUE((std::is_same<int&, decltype(base::get<2>(t))>::value));
128 EXPECT_EQ(2, base::get<2>(t));
129
130 EXPECT_TRUE((std::is_same<int&&,
131 decltype(base::get<0>(std::move(t)))>::value));
132 EXPECT_EQ(3, base::get<0>(std::move(t)));
133
134 EXPECT_TRUE((std::is_same<int&,
135 decltype(base::get<1>(std::move(t)))>::value));
136 EXPECT_EQ(1, base::get<1>(std::move(t)));
137
138 EXPECT_TRUE((std::is_same<int&&,
139 decltype(base::get<2>(std::move(t)))>::value));
140 EXPECT_EQ(2, base::get<2>(std::move(t)));
141 }
142
143 } // namespace base 117 } // namespace base
OLDNEW
« no previous file with comments | « base/tuple.h ('k') | styleguide/c++/c++11.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698