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

Unified Diff: base/containers/adapters_unittest.cc

Issue 1360423002: Extend base::Reversed to support iterating arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove clang-format directives Created 5 years, 2 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
« no previous file with comments | « base/containers/adapters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/adapters_unittest.cc
diff --git a/base/containers/adapters_unittest.cc b/base/containers/adapters_unittest.cc
index 4c874722b3fdb172d6d65cec41d36faa0af68fc1..92554b7e1e168b3b4bf9457f1d8d7414a415a9a1 100644
--- a/base/containers/adapters_unittest.cc
+++ b/base/containers/adapters_unittest.cc
@@ -25,7 +25,19 @@ TEST(AdaptersTest, Reversed) {
EXPECT_EQ(101, v[2]);
}
-TEST(AdaptersTest, ConstReversed) {
+TEST(AdaptersTest, ReversedArray) {
+ int v[3] = {3, 2, 1};
+ int j = 0;
+ for (int& i : base::Reversed(v)) {
+ EXPECT_EQ(++j, i);
+ i += 100;
+ }
+ EXPECT_EQ(103, v[0]);
+ EXPECT_EQ(102, v[1]);
+ EXPECT_EQ(101, v[2]);
+}
+
+TEST(AdaptersTest, ReversedConst) {
std::vector<int> v;
v.push_back(3);
v.push_back(2);
« no previous file with comments | « base/containers/adapters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698