llvm.org GIT mirror llvm / ba1f580
Move the SmallVector unit tests to be type-parameterized so that we can test more than a single instantiation of SmallVector. Add testing for 0, 1, 2, and 4 element sized "small" buffers. These appear to be essentially untested in the unit tests until now. Fix several tests to be robust in the face of a '0' small buffer. As a consequence of this size buffer, the growth patterns are actually observable in the test -- yes this means that many tests never caused a grow to occur before. For some tests I've merely added a reserve call to normalize behavior. For others, the growth is actually interesting, and so I captured the fact that growth would occur and adjusted the assertions to not assume how rapidly growth occured. Also update the specialization for a '0' small buffer length to have all the same interface points as the normal small vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161001 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
2 changed file(s) with 208 addition(s) and 167 deletion(s). Raw diff Collapse all Expand all
917917 template
918918 class SmallVector : public SmallVectorImpl {
919919 public:
920 SmallVector() : SmallVectorImpl(0) {}
920 SmallVector() : SmallVectorImpl(0) {
921 }
921922
922923 explicit SmallVector(unsigned Size, const T &Value = T())
923924 : SmallVectorImpl(0) {
930931 }
931932
932933 SmallVector(const SmallVector &RHS) : SmallVectorImpl(0) {
934 if (!RHS.empty())
935 SmallVectorImpl::operator=(RHS);
936 }
937
938 const SmallVector &operator=(const SmallVector &RHS) {
933939 SmallVectorImpl::operator=(RHS);
934 }
935
936 SmallVector &operator=(const SmallVectorImpl &RHS) {
937 return SmallVectorImpl::operator=(RHS);
938 }
939
940 return *this;
941 }
942
943 #if LLVM_USE_RVALUE_REFERENCES
944 SmallVector(SmallVector &&RHS) : SmallVectorImpl(0) {
945 if (!RHS.empty())
946 SmallVectorImpl::operator=(::std::move(RHS));
947 }
948
949 const SmallVector &operator=(SmallVector &&RHS) {
950 SmallVectorImpl::operator=(::std::move(RHS));
951 return *this;
952 }
953 #endif
940954 };
941955
942956 template
8787 int Constructable::numAssignmentCalls;
8888
8989 // Test fixture class
90 template
9091 class SmallVectorTest : public testing::Test {
9192 protected:
92 typedef SmallVector VectorType;
93
94 VectorType theVector;
95 VectorType otherVector;
93 VectorT theVector;
94 VectorT otherVector;
9695
9796 void SetUp() {
9897 Constructable::reset();
9998 }
10099
101 void assertEmpty(VectorType & v) {
100 void assertEmpty(VectorT & v) {
102101 // Size tests
103102 EXPECT_EQ(0u, v.size());
104103 EXPECT_TRUE(v.empty());
108107 }
109108
110109 // Assert that theVector contains the specified values, in order.
111 void assertValuesInOrder(VectorType & v, size_t size, ...) {
110 void assertValuesInOrder(VectorT & v, size_t size, ...) {
112111 EXPECT_EQ(size, v.size());
113112
114113 va_list ap;
122121 }
123122
124123 // Generate a sequence of values to initialize the vector.
125 void makeSequence(VectorType & v, int start, int end) {
124 void makeSequence(VectorT & v, int start, int end) {
126125 for (int i = start; i <= end; ++i) {
127126 v.push_back(Constructable(i));
128127 }
129128 }
130129 };
131130
131 typedef ::testing::Types,
132 SmallVector,
133 SmallVector,
134 SmallVector
135 > SmallVectorTestTypes;
136 TYPED_TEST_CASE(SmallVectorTest, SmallVectorTestTypes);
137
132138 // New vector test.
133 TEST_F(SmallVectorTest, EmptyVectorTest) {
139 TYPED_TEST(SmallVectorTest, EmptyVectorTest) {
134140 SCOPED_TRACE("EmptyVectorTest");
135 assertEmpty(theVector);
136 EXPECT_TRUE(theVector.rbegin() == theVector.rend());
141 this->assertEmpty(this->theVector);
142 EXPECT_TRUE(this->theVector.rbegin() == this->theVector.rend());
137143 EXPECT_EQ(0, Constructable::getNumConstructorCalls());
138144 EXPECT_EQ(0, Constructable::getNumDestructorCalls());
139145 }
140146
141147 // Simple insertions and deletions.
142 TEST_F(SmallVectorTest, PushPopTest) {
148 TYPED_TEST(SmallVectorTest, PushPopTest) {
143149 SCOPED_TRACE("PushPopTest");
144150
151 // Track whether the vector will potentially have to grow.
152 bool RequiresGrowth = this->theVector.capacity() < 3;
153
145154 // Push an element
146 theVector.push_back(Constructable(1));
155 this->theVector.push_back(Constructable(1));
147156
148157 // Size tests
149 assertValuesInOrder(theVector, 1u, 1);
150 EXPECT_FALSE(theVector.begin() == theVector.end());
151 EXPECT_FALSE(theVector.empty());
158 this->assertValuesInOrder(this->theVector, 1u, 1);
159 EXPECT_FALSE(this->theVector.begin() == this->theVector.end());
160 EXPECT_FALSE(this->theVector.empty());
152161
153162 // Push another element
154 theVector.push_back(Constructable(2));
155 assertValuesInOrder(theVector, 2u, 1, 2);
163 this->theVector.push_back(Constructable(2));
164 this->assertValuesInOrder(this->theVector, 2u, 1, 2);
156165
157166 // Insert at beginning
158 theVector.insert(theVector.begin(), theVector[1]);
159 assertValuesInOrder(theVector, 3u, 2, 1, 2);
167 this->theVector.insert(this->theVector.begin(), this->theVector[1]);
168 this->assertValuesInOrder(this->theVector, 3u, 2, 1, 2);
160169
161170 // Pop one element
162 theVector.pop_back();
163 assertValuesInOrder(theVector, 2u, 2, 1);
171 this->theVector.pop_back();
172 this->assertValuesInOrder(this->theVector, 2u, 2, 1);
164173
165174 // Pop remaining elements
166 theVector.pop_back();
167 theVector.pop_back();
168 assertEmpty(theVector);
175 this->theVector.pop_back();
176 this->theVector.pop_back();
177 this->assertEmpty(this->theVector);
169178
170179 // Check number of constructor calls. Should be 2 for each list element,
171180 // one for the argument to push_back, one for the argument to insert,
172181 // and one for the list element itself.
173 EXPECT_EQ(5, Constructable::getNumConstructorCalls());
174 EXPECT_EQ(5, Constructable::getNumDestructorCalls());
182 if (!RequiresGrowth) {
183 EXPECT_EQ(5, Constructable::getNumConstructorCalls());
184 EXPECT_EQ(5, Constructable::getNumDestructorCalls());
185 } else {
186 // If we had to grow the vector, these only have a lower bound, but should
187 // always be equal.
188 EXPECT_LE(5, Constructable::getNumConstructorCalls());
189 EXPECT_EQ(Constructable::getNumConstructorCalls(),
190 Constructable::getNumDestructorCalls());
191 }
175192 }
176193
177194 // Clear test.
178 TEST_F(SmallVectorTest, ClearTest) {
195 TYPED_TEST(SmallVectorTest, ClearTest) {
179196 SCOPED_TRACE("ClearTest");
180197
181 makeSequence(theVector, 1, 2);
182 theVector.clear();
183
184 assertEmpty(theVector);
198 this->theVector.reserve(2);
199 this->makeSequence(this->theVector, 1, 2);
200 this->theVector.clear();
201
202 this->assertEmpty(this->theVector);
185203 EXPECT_EQ(4, Constructable::getNumConstructorCalls());
186204 EXPECT_EQ(4, Constructable::getNumDestructorCalls());
187205 }
188206
189207 // Resize smaller test.
190 TEST_F(SmallVectorTest, ResizeShrinkTest) {
208 TYPED_TEST(SmallVectorTest, ResizeShrinkTest) {
191209 SCOPED_TRACE("ResizeShrinkTest");
192210
193 makeSequence(theVector, 1, 3);
194 theVector.resize(1);
195
196 assertValuesInOrder(theVector, 1u, 1);
211 this->theVector.reserve(3);
212 this->makeSequence(this->theVector, 1, 3);
213 this->theVector.resize(1);
214
215 this->assertValuesInOrder(this->theVector, 1u, 1);
197216 EXPECT_EQ(6, Constructable::getNumConstructorCalls());
198217 EXPECT_EQ(5, Constructable::getNumDestructorCalls());
199218 }
200219
201220 // Resize bigger test.
202 TEST_F(SmallVectorTest, ResizeGrowTest) {
221 TYPED_TEST(SmallVectorTest, ResizeGrowTest) {
203222 SCOPED_TRACE("ResizeGrowTest");
204223
205 theVector.resize(2);
224 this->theVector.resize(2);
206225
207226 // The extra constructor/destructor calls come from the temporary object used
208227 // to initialize the contents of the resized array (via copy construction).
209228 EXPECT_EQ(3, Constructable::getNumConstructorCalls());
210229 EXPECT_EQ(1, Constructable::getNumDestructorCalls());
211 EXPECT_EQ(2u, theVector.size());
230 EXPECT_EQ(2u, this->theVector.size());
212231 }
213232
214233 // Resize with fill value.
215 TEST_F(SmallVectorTest, ResizeFillTest) {
234 TYPED_TEST(SmallVectorTest, ResizeFillTest) {
216235 SCOPED_TRACE("ResizeFillTest");
217236
218 theVector.resize(3, Constructable(77));
219 assertValuesInOrder(theVector, 3u, 77, 77, 77);
237 this->theVector.resize(3, Constructable(77));
238 this->assertValuesInOrder(this->theVector, 3u, 77, 77, 77);
220239 }
221240
222241 // Overflow past fixed size.
223 TEST_F(SmallVectorTest, OverflowTest) {
242 TYPED_TEST(SmallVectorTest, OverflowTest) {
224243 SCOPED_TRACE("OverflowTest");
225244
226245 // Push more elements than the fixed size.
227 makeSequence(theVector, 1, 10);
246 this->makeSequence(this->theVector, 1, 10);
228247
229248 // Test size and values.
230 EXPECT_EQ(10u, theVector.size());
249 EXPECT_EQ(10u, this->theVector.size());
231250 for (int i = 0; i < 10; ++i) {
232 EXPECT_EQ(i+1, theVector[i].getValue());
251 EXPECT_EQ(i+1, this->theVector[i].getValue());
233252 }
234253
235254 // Now resize back to fixed size.
236 theVector.resize(1);
237
238 assertValuesInOrder(theVector, 1u, 1);
255 this->theVector.resize(1);
256
257 this->assertValuesInOrder(this->theVector, 1u, 1);
239258 }
240259
241260 // Iteration tests.
242 TEST_F(SmallVectorTest, IterationTest) {
243 makeSequence(theVector, 1, 2);
261 TYPED_TEST(SmallVectorTest, IterationTest) {
262 this->makeSequence(this->theVector, 1, 2);
244263
245264 // Forward Iteration
246 VectorType::iterator it = theVector.begin();
247 EXPECT_TRUE(*it == theVector.front());
248 EXPECT_TRUE(*it == theVector[0]);
265 typename TypeParam::iterator it = this->theVector.begin();
266 EXPECT_TRUE(*it == this->theVector.front());
267 EXPECT_TRUE(*it == this->theVector[0]);
249268 EXPECT_EQ(1, it->getValue());
250269 ++it;
251 EXPECT_TRUE(*it == theVector[1]);
252 EXPECT_TRUE(*it == theVector.back());
270 EXPECT_TRUE(*it == this->theVector[1]);
271 EXPECT_TRUE(*it == this->theVector.back());
253272 EXPECT_EQ(2, it->getValue());
254273 ++it;
255 EXPECT_TRUE(it == theVector.end());
274 EXPECT_TRUE(it == this->theVector.end());
256275 --it;
257 EXPECT_TRUE(*it == theVector[1]);
276 EXPECT_TRUE(*it == this->theVector[1]);
258277 EXPECT_EQ(2, it->getValue());
259278 --it;
260 EXPECT_TRUE(*it == theVector[0]);
279 EXPECT_TRUE(*it == this->theVector[0]);
261280 EXPECT_EQ(1, it->getValue());
262281
263282 // Reverse Iteration
264 VectorType::reverse_iterator rit = theVector.rbegin();
265 EXPECT_TRUE(*rit == theVector[1]);
283 typename TypeParam::reverse_iterator rit = this->theVector.rbegin();
284 EXPECT_TRUE(*rit == this->theVector[1]);
266285 EXPECT_EQ(2, rit->getValue());
267286 ++rit;
268 EXPECT_TRUE(*rit == theVector[0]);
287 EXPECT_TRUE(*rit == this->theVector[0]);
269288 EXPECT_EQ(1, rit->getValue());
270289 ++rit;
271 EXPECT_TRUE(rit == theVector.rend());
290 EXPECT_TRUE(rit == this->theVector.rend());
272291 --rit;
273 EXPECT_TRUE(*rit == theVector[0]);
292 EXPECT_TRUE(*rit == this->theVector[0]);
274293 EXPECT_EQ(1, rit->getValue());
275294 --rit;
276 EXPECT_TRUE(*rit == theVector[1]);
295 EXPECT_TRUE(*rit == this->theVector[1]);
277296 EXPECT_EQ(2, rit->getValue());
278297 }
279298
280299 // Swap test.
281 TEST_F(SmallVectorTest, SwapTest) {
300 TYPED_TEST(SmallVectorTest, SwapTest) {
282301 SCOPED_TRACE("SwapTest");
283302
284 makeSequence(theVector, 1, 2);
285 std::swap(theVector, otherVector);
286
287 assertEmpty(theVector);
288 assertValuesInOrder(otherVector, 2u, 1, 2);
303 this->makeSequence(this->theVector, 1, 2);
304 std::swap(this->theVector, this->otherVector);
305
306 this->assertEmpty(this->theVector);
307 this->assertValuesInOrder(this->otherVector, 2u, 1, 2);
289308 }
290309
291310 // Append test
292 TEST_F(SmallVectorTest, AppendTest) {
311 TYPED_TEST(SmallVectorTest, AppendTest) {
293312 SCOPED_TRACE("AppendTest");
294313
295 makeSequence(otherVector, 2, 3);
296
297 theVector.push_back(Constructable(1));
298 theVector.append(otherVector.begin(), otherVector.end());
299
300 assertValuesInOrder(theVector, 3u, 1, 2, 3);
314 this->makeSequence(this->otherVector, 2, 3);
315
316 this->theVector.push_back(Constructable(1));
317 this->theVector.append(this->otherVector.begin(), this->otherVector.end());
318
319 this->assertValuesInOrder(this->theVector, 3u, 1, 2, 3);
301320 }
302321
303322 // Append repeated test
304 TEST_F(SmallVectorTest, AppendRepeatedTest) {
323 TYPED_TEST(SmallVectorTest, AppendRepeatedTest) {
305324 SCOPED_TRACE("AppendRepeatedTest");
306325
307 theVector.push_back(Constructable(1));
308 theVector.append(2, Constructable(77));
309 assertValuesInOrder(theVector, 3u, 1, 77, 77);
326 this->theVector.push_back(Constructable(1));
327 this->theVector.append(2, Constructable(77));
328 this->assertValuesInOrder(this->theVector, 3u, 1, 77, 77);
310329 }
311330
312331 // Assign test
313 TEST_F(SmallVectorTest, AssignTest) {
332 TYPED_TEST(SmallVectorTest, AssignTest) {
314333 SCOPED_TRACE("AssignTest");
315334
316 theVector.push_back(Constructable(1));
317 theVector.assign(2, Constructable(77));
318 assertValuesInOrder(theVector, 2u, 77, 77);
335 this->theVector.push_back(Constructable(1));
336 this->theVector.assign(2, Constructable(77));
337 this->assertValuesInOrder(this->theVector, 2u, 77, 77);
319338 }
320339
321340 // Erase a single element
322 TEST_F(SmallVectorTest, EraseTest) {
341 TYPED_TEST(SmallVectorTest, EraseTest) {
323342 SCOPED_TRACE("EraseTest");
324343
325 makeSequence(theVector, 1, 3);
326 theVector.erase(theVector.begin());
327 assertValuesInOrder(theVector, 2u, 2, 3);
344 this->makeSequence(this->theVector, 1, 3);
345 this->theVector.erase(this->theVector.begin());
346 this->assertValuesInOrder(this->theVector, 2u, 2, 3);
328347 }
329348
330349 // Erase a range of elements
331 TEST_F(SmallVectorTest, EraseRangeTest) {
350 TYPED_TEST(SmallVectorTest, EraseRangeTest) {
332351 SCOPED_TRACE("EraseRangeTest");
333352
334 makeSequence(theVector, 1, 3);
335 theVector.erase(theVector.begin(), theVector.begin() + 2);
336 assertValuesInOrder(theVector, 1u, 3);
353 this->makeSequence(this->theVector, 1, 3);
354 this->theVector.erase(this->theVector.begin(), this->theVector.begin() + 2);
355 this->assertValuesInOrder(this->theVector, 1u, 3);
337356 }
338357
339358 // Insert a single element.
340 TEST_F(SmallVectorTest, InsertTest) {
359 TYPED_TEST(SmallVectorTest, InsertTest) {
341360 SCOPED_TRACE("InsertTest");
342361
343 makeSequence(theVector, 1, 3);
344 VectorType::iterator I =
345 theVector.insert(theVector.begin() + 1, Constructable(77));
346 EXPECT_EQ(theVector.begin() + 1, I);
347 assertValuesInOrder(theVector, 4u, 1, 77, 2, 3);
362 this->makeSequence(this->theVector, 1, 3);
363 typename TypeParam::iterator I =
364 this->theVector.insert(this->theVector.begin() + 1, Constructable(77));
365 EXPECT_EQ(this->theVector.begin() + 1, I);
366 this->assertValuesInOrder(this->theVector, 4u, 1, 77, 2, 3);
348367 }
349368
350369 // Insert repeated elements.
351 TEST_F(SmallVectorTest, InsertRepeatedTest) {
370 TYPED_TEST(SmallVectorTest, InsertRepeatedTest) {
352371 SCOPED_TRACE("InsertRepeatedTest");
353372
354 makeSequence(theVector, 10, 15);
355 VectorType::iterator I =
356 theVector.insert(theVector.begin() + 1, 2, Constructable(16));
357 EXPECT_EQ(theVector.begin() + 1, I);
358 assertValuesInOrder(theVector, 8u, 10, 16, 16, 11, 12, 13, 14, 15);
373 this->makeSequence(this->theVector, 10, 15);
374 typename TypeParam::iterator I =
375 this->theVector.insert(this->theVector.begin() + 1, 2, Constructable(16));
376 EXPECT_EQ(this->theVector.begin() + 1, I);
377 this->assertValuesInOrder(this->theVector, 8u,
378 10, 16, 16, 11, 12, 13, 14, 15);
359379
360380 // Insert at end.
361 I = theVector.insert(theVector.end(), 2, Constructable(16));
362 EXPECT_EQ(theVector.begin() + 8, I);
363 assertValuesInOrder(theVector, 10u, 10, 16, 16, 11, 12, 13, 14, 15, 16, 16);
381 I = this->theVector.insert(this->theVector.end(), 2, Constructable(16));
382 EXPECT_EQ(this->theVector.begin() + 8, I);
383 this->assertValuesInOrder(this->theVector, 10u,
384 10, 16, 16, 11, 12, 13, 14, 15, 16, 16);
364385
365386 // Empty insert.
366 EXPECT_EQ(theVector.end(),
367 theVector.insert(theVector.end(), 0, Constructable(42)));
368 EXPECT_EQ(theVector.begin() + 1,
369 theVector.insert(theVector.begin() + 1, 0, Constructable(42)));
387 EXPECT_EQ(this->theVector.end(),
388 this->theVector.insert(this->theVector.end(),
389 0, Constructable(42)));
390 EXPECT_EQ(this->theVector.begin() + 1,
391 this->theVector.insert(this->theVector.begin() + 1,
392 0, Constructable(42)));
370393 }
371394
372395 // Insert range.
373 TEST_F(SmallVectorTest, InsertRangeTest) {
396 TYPED_TEST(SmallVectorTest, InsertRangeTest) {
374397 SCOPED_TRACE("InsertRangeTest");
375398
376399 Constructable Arr[3] =
377400 { Constructable(77), Constructable(77), Constructable(77) };
378401
379 makeSequence(theVector, 1, 3);
380 VectorType::iterator I =
381 theVector.insert(theVector.begin() + 1, Arr, Arr+3);
382 EXPECT_EQ(theVector.begin() + 1, I);
383 assertValuesInOrder(theVector, 6u, 1, 77, 77, 77, 2, 3);
402 this->makeSequence(this->theVector, 1, 3);
403 typename TypeParam::iterator I =
404 this->theVector.insert(this->theVector.begin() + 1, Arr, Arr+3);
405 EXPECT_EQ(this->theVector.begin() + 1, I);
406 this->assertValuesInOrder(this->theVector, 6u, 1, 77, 77, 77, 2, 3);
384407
385408 // Insert at end.
386 I = theVector.insert(theVector.end(), Arr, Arr+3);
387 EXPECT_EQ(theVector.begin() + 6, I);
388 assertValuesInOrder(theVector, 9u, 1, 77, 77, 77, 2, 3, 77, 77, 77);
409 I = this->theVector.insert(this->theVector.end(), Arr, Arr+3);
410 EXPECT_EQ(this->theVector.begin() + 6, I);
411 this->assertValuesInOrder(this->theVector, 9u,
412 1, 77, 77, 77, 2, 3, 77, 77, 77);
389413
390414 // Empty insert.
391 EXPECT_EQ(theVector.end(), theVector.insert(theVector.end(),
392 theVector.begin(),
393 theVector.begin()));
394 EXPECT_EQ(theVector.begin() + 1, theVector.insert(theVector.begin() + 1,
395 theVector.begin(),
396 theVector.begin()));
415 EXPECT_EQ(this->theVector.end(),
416 this->theVector.insert(this->theVector.end(),
417 this->theVector.begin(),
418 this->theVector.begin()));
419 EXPECT_EQ(this->theVector.begin() + 1,
420 this->theVector.insert(this->theVector.begin() + 1,
421 this->theVector.begin(),
422 this->theVector.begin()));
397423 }
398424
399425 // Comparison tests.
400 TEST_F(SmallVectorTest, ComparisonTest) {
426 TYPED_TEST(SmallVectorTest, ComparisonTest) {
401427 SCOPED_TRACE("ComparisonTest");
402428
403 makeSequence(theVector, 1, 3);
404 makeSequence(otherVector, 1, 3);
405
406 EXPECT_TRUE(theVector == otherVector);
407 EXPECT_FALSE(theVector != otherVector);
408
409 otherVector.clear();
410 makeSequence(otherVector, 2, 4);
411
412 EXPECT_FALSE(theVector == otherVector);
413 EXPECT_TRUE(theVector != otherVector);
429 this->makeSequence(this->theVector, 1, 3);
430 this->makeSequence(this->otherVector, 1, 3);
431
432 EXPECT_TRUE(this->theVector == this->otherVector);
433 EXPECT_FALSE(this->theVector != this->otherVector);
434
435 this->otherVector.clear();
436 this->makeSequence(this->otherVector, 2, 4);
437
438 EXPECT_FALSE(this->theVector == this->otherVector);
439 EXPECT_TRUE(this->theVector != this->otherVector);
414440 }
415441
416442 // Constant vector tests.
417 TEST_F(SmallVectorTest, ConstVectorTest) {
418 VectorType constVector;
443 TYPED_TEST(SmallVectorTest, ConstVectorTest) {
444 const TypeParam constVector;
419445
420446 EXPECT_EQ(0u, constVector.size());
421447 EXPECT_TRUE(constVector.empty());
423449 }
424450
425451 // Direct array access.
426 TEST_F(SmallVectorTest, DirectVectorTest) {
427 EXPECT_EQ(0u, theVector.size());
428 EXPECT_LE(4u, theVector.capacity());
452 TYPED_TEST(SmallVectorTest, DirectVectorTest) {
453 EXPECT_EQ(0u, this->theVector.size());
454 this->theVector.reserve(4);
455 EXPECT_LE(4u, this->theVector.capacity());
429456 EXPECT_EQ(0, Constructable::getNumConstructorCalls());
430 theVector.end()[0] = 1;
431 theVector.end()[1] = 2;
432 theVector.end()[2] = 3;
433 theVector.end()[3] = 4;
434 theVector.set_size(4);
435 EXPECT_EQ(4u, theVector.size());
457 this->theVector.end()[0] = 1;
458 this->theVector.end()[1] = 2;
459 this->theVector.end()[2] = 3;
460 this->theVector.end()[3] = 4;
461 this->theVector.set_size(4);
462 EXPECT_EQ(4u, this->theVector.size());
436463 EXPECT_EQ(4, Constructable::getNumConstructorCalls());
437 EXPECT_EQ(1, theVector[0].getValue());
438 EXPECT_EQ(2, theVector[1].getValue());
439 EXPECT_EQ(3, theVector[2].getValue());
440 EXPECT_EQ(4, theVector[3].getValue());
441 }
442
443 TEST_F(SmallVectorTest, IteratorTest) {
464 EXPECT_EQ(1, this->theVector[0].getValue());
465 EXPECT_EQ(2, this->theVector[1].getValue());
466 EXPECT_EQ(3, this->theVector[2].getValue());
467 EXPECT_EQ(4, this->theVector[3].getValue());
468 }
469
470 TYPED_TEST(SmallVectorTest, IteratorTest) {
444471 std::list L;
445 theVector.insert(theVector.end(), L.begin(), L.end());
472 this->theVector.insert(this->theVector.end(), L.begin(), L.end());
446473 }
447474
448475 struct notassignable {
450477 notassignable(int &x) : x(x) {}
451478 };
452479
453 TEST_F(SmallVectorTest, NoAssignTest) {
480 TEST(SmallVectorCustomTest, NoAssignTest) {
454481 int x = 0;
455482 SmallVector vec;
456483 vec.push_back(notassignable(x));