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

Side by Side Diff: third_party/WebKit/Source/wtf/VectorTest.cpp

Issue 1370933002: Return early for vec.remove(position, 0). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 5 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/wtf/Vector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 intVector.append(9); 61 intVector.append(9);
62 intVector.reverse(); 62 intVector.reverse();
63 63
64 EXPECT_EQ(9, intVector[0]); 64 EXPECT_EQ(9, intVector[0]);
65 EXPECT_EQ(10, intVector[1]); 65 EXPECT_EQ(10, intVector[1]);
66 EXPECT_EQ(11, intVector[2]); 66 EXPECT_EQ(11, intVector[2]);
67 EXPECT_EQ(12, intVector[3]); 67 EXPECT_EQ(12, intVector[3]);
68 EXPECT_EQ(13, intVector[4]); 68 EXPECT_EQ(13, intVector[4]);
69 } 69 }
70 70
71 TEST(VectorTest, Remove)
72 {
73 Vector<int> intVector;
74 intVector.append(0);
75 intVector.append(1);
76 intVector.append(2);
77 intVector.append(3);
78
79 EXPECT_EQ(4u, intVector.size());
80 EXPECT_EQ(0, intVector[0]);
81 EXPECT_EQ(1, intVector[1]);
82 EXPECT_EQ(2, intVector[2]);
83 EXPECT_EQ(3, intVector[3]);
84
85 intVector.remove(2, 0);
86 EXPECT_EQ(4u, intVector.size());
87 EXPECT_EQ(2, intVector[2]);
88
89 intVector.remove(2, 1);
90 EXPECT_EQ(3u, intVector.size());
91 EXPECT_EQ(3, intVector[2]);
92
93 intVector.remove(0, 0);
94 EXPECT_EQ(3u, intVector.size());
95 EXPECT_EQ(0, intVector[0]);
96
97 intVector.remove(0);
98 EXPECT_EQ(2u, intVector.size());
99 EXPECT_EQ(1, intVector[0]);
100 }
101
71 TEST(VectorTest, Iterator) 102 TEST(VectorTest, Iterator)
72 { 103 {
73 Vector<int> intVector; 104 Vector<int> intVector;
74 intVector.append(10); 105 intVector.append(10);
75 intVector.append(11); 106 intVector.append(11);
76 intVector.append(12); 107 intVector.append(12);
77 intVector.append(13); 108 intVector.append(13);
78 109
79 Vector<int>::iterator it = intVector.begin(); 110 Vector<int>::iterator it = intVector.begin();
80 Vector<int>::iterator end = intVector.end(); 111 Vector<int>::iterator end = intVector.end();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 TEST(VectorTest, Compare) 377 TEST(VectorTest, Compare)
347 { 378 {
348 compare<int>(); 379 compare<int>();
349 compare<Comparable>(); 380 compare<Comparable>();
350 compare<WTF::String>(); 381 compare<WTF::String>();
351 } 382 }
352 383
353 } // anonymous namespace 384 } // anonymous namespace
354 385
355 } // namespace WTF 386 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698