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

Unified Diff: base/tuple_unittest.cc

Issue 2047013002: Add base::get to support rvalue-reference tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +test case Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: base/tuple_unittest.cc
diff --git a/base/tuple_unittest.cc b/base/tuple_unittest.cc
index 815b43bb1b3236b10cc5a142b4d5ef1e264d84b1..6f90c2922064610cb7426cad5095cc2bc042a01f 100644
--- a/base/tuple_unittest.cc
+++ b/base/tuple_unittest.cc
@@ -114,4 +114,30 @@ TEST(TupleTest, Copying) {
EXPECT_EQ(2, CopyLogger::TimesCopied);
}
+TEST(TupleTest, Get) {
+ int i = 1;
+ int j = 2;
+ std::tuple<int, int&, int&&> t(3, i, std::move(j));
+ EXPECT_TRUE((std::is_same<int&, decltype(base::get<0>(t))>::value));
+ EXPECT_EQ(3, base::get<0>(t));
+
+ EXPECT_TRUE((std::is_same<int&, decltype(base::get<1>(t))>::value));
+ EXPECT_EQ(1, base::get<1>(t));
+
+ EXPECT_TRUE((std::is_same<int&, decltype(base::get<2>(t))>::value));
+ EXPECT_EQ(2, base::get<2>(t));
+
+ EXPECT_TRUE((std::is_same<int&&,
+ decltype(base::get<0>(std::move(t)))>::value));
+ EXPECT_EQ(3, base::get<0>(std::move(t)));
+
+ EXPECT_TRUE((std::is_same<int&,
+ decltype(base::get<1>(std::move(t)))>::value));
+ EXPECT_EQ(1, base::get<1>(std::move(t)));
+
+ EXPECT_TRUE((std::is_same<int&&,
+ decltype(base::get<2>(std::move(t)))>::value));
+ EXPECT_EQ(2, base::get<2>(std::move(t)));
+}
+
} // namespace base
« no previous file with comments | « base/tuple.h ('k') | styleguide/c++/c++11.html » ('j') | styleguide/c++/c++11.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698