OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/zone/zone-chunk-list.h" | 5 #include "src/zone/zone-chunk-list.h" |
6 | 6 |
7 #include "src/list-inl.h" | 7 #include "src/list-inl.h" |
8 #include "src/zone/accounting-allocator.h" | 8 #include "src/zone/accounting-allocator.h" |
9 #include "src/zone/zone.h" | 9 #include "src/zone/zone.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 zone_chunk_list.Rewind(42); | 87 zone_chunk_list.Rewind(42); |
88 | 88 |
89 size_t count = 0; | 89 size_t count = 0; |
90 | 90 |
91 for (uintptr_t item : zone_chunk_list) { | 91 for (uintptr_t item : zone_chunk_list) { |
92 EXPECT_EQ(static_cast<size_t>(item), count); | 92 EXPECT_EQ(static_cast<size_t>(item), count); |
93 count++; | 93 count++; |
94 } | 94 } |
95 | 95 |
96 EXPECT_EQ(count, 42); | 96 EXPECT_EQ(count, 42u); |
97 EXPECT_EQ(count, zone_chunk_list.size()); | 97 EXPECT_EQ(count, zone_chunk_list.size()); |
98 | 98 |
99 zone_chunk_list.Rewind(0); | 99 zone_chunk_list.Rewind(0); |
100 | 100 |
101 count = 0; | 101 count = 0; |
102 | 102 |
103 for (uintptr_t item : zone_chunk_list) { | 103 for (uintptr_t item : zone_chunk_list) { |
104 USE(item); | 104 USE(item); |
105 count++; | 105 count++; |
106 } | 106 } |
107 | 107 |
108 EXPECT_EQ(count, 0); | 108 EXPECT_EQ(count, 0u); |
109 EXPECT_EQ(count, zone_chunk_list.size()); | 109 EXPECT_EQ(count, zone_chunk_list.size()); |
110 | 110 |
111 zone_chunk_list.Rewind(100); | 111 zone_chunk_list.Rewind(100); |
112 | 112 |
113 count = 0; | 113 count = 0; |
114 | 114 |
115 for (uintptr_t item : zone_chunk_list) { | 115 for (uintptr_t item : zone_chunk_list) { |
116 EXPECT_EQ(static_cast<size_t>(item), count); | 116 EXPECT_EQ(static_cast<size_t>(item), count); |
117 count++; | 117 count++; |
118 } | 118 } |
119 | 119 |
120 EXPECT_EQ(count, 0); | 120 EXPECT_EQ(count, 0u); |
121 EXPECT_EQ(count, zone_chunk_list.size()); | 121 EXPECT_EQ(count, zone_chunk_list.size()); |
122 } | 122 } |
123 | 123 |
124 TEST(ZoneChunkList, FindTest) { | 124 TEST(ZoneChunkList, FindTest) { |
125 AccountingAllocator allocator; | 125 AccountingAllocator allocator; |
126 Zone zone(&allocator, ZONE_NAME); | 126 Zone zone(&allocator, ZONE_NAME); |
127 | 127 |
128 ZoneChunkList<uintptr_t> zone_chunk_list(&zone); | 128 ZoneChunkList<uintptr_t> zone_chunk_list(&zone); |
129 | 129 |
130 for (size_t i = 0; i < kItemCount; ++i) { | 130 for (size_t i = 0; i < kItemCount; ++i) { |
131 zone_chunk_list.push_back(static_cast<uintptr_t>(i)); | 131 zone_chunk_list.push_back(static_cast<uintptr_t>(i)); |
132 } | 132 } |
133 | 133 |
134 const size_t index = kItemCount / 2 + 42; | 134 const size_t index = kItemCount / 2 + 42; |
135 | 135 |
136 EXPECT_EQ(*zone_chunk_list.Find(index), static_cast<uintptr_t>(index)); | 136 EXPECT_EQ(*zone_chunk_list.Find(index), static_cast<uintptr_t>(index)); |
137 | 137 |
138 *zone_chunk_list.Find(index) = 42; | 138 *zone_chunk_list.Find(index) = 42; |
139 | 139 |
140 EXPECT_EQ(*zone_chunk_list.Find(index), 42); | 140 EXPECT_EQ(*zone_chunk_list.Find(index), 42u); |
141 } | 141 } |
142 | 142 |
143 TEST(ZoneChunkList, CopyToTest) { | 143 TEST(ZoneChunkList, CopyToTest) { |
144 AccountingAllocator allocator; | 144 AccountingAllocator allocator; |
145 Zone zone(&allocator, ZONE_NAME); | 145 Zone zone(&allocator, ZONE_NAME); |
146 | 146 |
147 ZoneChunkList<uintptr_t> zone_chunk_list(&zone); | 147 ZoneChunkList<uintptr_t> zone_chunk_list(&zone); |
148 | 148 |
149 for (size_t i = 0; i < kItemCount; ++i) { | 149 for (size_t i = 0; i < kItemCount; ++i) { |
150 zone_chunk_list.push_back(static_cast<uintptr_t>(i)); | 150 zone_chunk_list.push_back(static_cast<uintptr_t>(i)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 zone_chunk_list.CopyTo(array); | 198 zone_chunk_list.CopyTo(array); |
199 | 199 |
200 for (size_t i = 0; i < kItemCount; ++i) { | 200 for (size_t i = 0; i < kItemCount; ++i) { |
201 EXPECT_EQ(array[i].a_, i); | 201 EXPECT_EQ(array[i].a_, i); |
202 EXPECT_EQ(array[i].b_, i + 5); | 202 EXPECT_EQ(array[i].b_, i + 5); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 } // namespace internal | 206 } // namespace internal |
207 } // namespace v8 | 207 } // namespace v8 |
OLD | NEW |