OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 "src/base/iterator.h" | 5 #include "src/base/iterator.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 base::iterator_range<int*> r2(&array[0], &array[0]); | 35 base::iterator_range<int*> r2(&array[0], &array[0]); |
36 EXPECT_EQ(0, r2.size()); | 36 EXPECT_EQ(0, r2.size()); |
37 EXPECT_TRUE(r2.empty()); | 37 EXPECT_TRUE(r2.empty()); |
38 for (auto i : array) { | 38 for (auto i : array) { |
39 EXPECT_EQ(r2.end(), std::find(r2.begin(), r2.end(), i)); | 39 EXPECT_EQ(r2.end(), std::find(r2.begin(), r2.end(), i)); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 TEST(IteratorTest, IteratorRangeDeque) { | 44 TEST(IteratorTest, IteratorRangeDeque) { |
45 typedef std::deque<unsigned> C; | 45 typedef std::deque<int> C; |
46 C c; | 46 C c; |
47 c.push_back(1); | 47 c.push_back(1); |
48 c.push_back(2); | 48 c.push_back(2); |
49 c.push_back(2); | 49 c.push_back(2); |
50 base::iterator_range<typename C::iterator> r(c.begin(), c.end()); | 50 base::iterator_range<typename C::iterator> r(c.begin(), c.end()); |
51 EXPECT_EQ(3, r.size()); | 51 EXPECT_EQ(3, r.size()); |
52 EXPECT_FALSE(r.empty()); | 52 EXPECT_FALSE(r.empty()); |
53 EXPECT_TRUE(c.begin() == r.begin()); | 53 EXPECT_TRUE(c.begin() == r.begin()); |
54 EXPECT_TRUE(c.end() == r.end()); | 54 EXPECT_TRUE(c.end() == r.end()); |
55 EXPECT_EQ(0, std::count(r.begin(), r.end(), 0)); | 55 EXPECT_EQ(0, std::count(r.begin(), r.end(), 0)); |
56 EXPECT_EQ(1, std::count(r.begin(), r.end(), 1)); | 56 EXPECT_EQ(1, std::count(r.begin(), r.end(), 1)); |
57 EXPECT_EQ(2, std::count(r.begin(), r.end(), 2)); | 57 EXPECT_EQ(2, std::count(r.begin(), r.end(), 2)); |
58 } | 58 } |
59 | 59 |
60 } // namespace base | 60 } // namespace base |
61 } // namespace v8 | 61 } // namespace v8 |
OLD | NEW |