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.
6 #include "public/platform/WebVector.h"
8 #include "wtf/Vector.h"
9 #include <gtest/gtest.h>
13 TEST(WebVectorTest
, beginend
)
16 for (int i
= 0; i
< 5; ++i
)
19 WebVector
<int> webVector(input
);
20 ASSERT_EQ(input
.size(), webVector
.size());
22 EXPECT_EQ(webVector
.data(), webVector
.begin());
23 EXPECT_EQ(webVector
.data() + webVector
.size(), webVector
.end());
25 // Use begin()/end() iterators directly.
27 for (WebVector
<int>::iterator it
= webVector
.begin(); it
!= webVector
.end(); ++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
]);
33 // Use begin()/end() const_iterators directly.
35 const WebVector
<int>& constWebVector
= webVector
;
36 for (WebVector
<int>::const_iterator it
= constWebVector
.begin(); it
!= constWebVector
.end(); ++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
]);
42 // Use range-based for loop.
44 for (int x
: webVector
)
46 ASSERT_EQ(input
.size(), output
.size());
47 for (size_t i
= 0; i
< input
.size(); ++i
)
48 EXPECT_EQ(input
[i
], output
[i
]);