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

Side by Side Diff: Source/platform/WebVectorTest.cpp

Issue 1014933002: Add begin()/end() to WebVector to enable range-based for loops (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move test to Source/platform/ Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "public/platform/WebVector.h"
7
8 #include "wtf/Vector.h"
9 #include <gtest/gtest.h>
10
11 namespace blink {
12
13 TEST(WebVectorTest, beginend)
14 {
15 Vector<int> input;
16 for (int i = 0; i < 5; ++i)
17 input.append(i);
18
19 WebVector<int> webVector(input);
20 ASSERT_EQ(input.size(), webVector.size());
21
22 EXPECT_EQ(webVector.data(), webVector.begin());
23 EXPECT_EQ(webVector.data() + webVector.size(), webVector.end());
24
25 // Use begin()/end() iterators directly.
26 Vector<int> output;
27 for (WebVector<int>::iterator it = webVector.begin(); it != webVector.end(); ++it)
28 output.append(*it);
29 ASSERT_EQ(input.size(), output.size());
30 for (size_t i = 0; i < input.size(); ++i)
31 EXPECT_EQ(input[i], output[i]);
32
33 // Use begin()/end() const_iterators directly.
34 output.clear();
35 const WebVector<int>& constWebVector = webVector;
36 for (WebVector<int>::const_iterator it = constWebVector.begin(); it != const WebVector.end(); ++it)
37 output.append(*it);
38 ASSERT_EQ(input.size(), output.size());
39 for (size_t i = 0; i < input.size(); ++i)
40 EXPECT_EQ(input[i], output[i]);
41
42 // Use range-based for loop.
43 output.clear();
44 for (int x : webVector)
45 output.append(x);
46 ASSERT_EQ(input.size(), output.size());
47 for (size_t i = 0; i < input.size(); ++i)
48 EXPECT_EQ(input[i], output[i]);
49 }
50
51 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698