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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/Vector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/VectorTest.cpp
diff --git a/third_party/WebKit/Source/wtf/VectorTest.cpp b/third_party/WebKit/Source/wtf/VectorTest.cpp
index 7d27c508fddae3e40a45c758720aea32d0f68a0d..89f4eb14fcf2c5a7370b05c1e84737083aece7ee 100644
--- a/third_party/WebKit/Source/wtf/VectorTest.cpp
+++ b/third_party/WebKit/Source/wtf/VectorTest.cpp
@@ -68,6 +68,37 @@ TEST(VectorTest, Reverse)
EXPECT_EQ(13, intVector[4]);
}
+TEST(VectorTest, Remove)
+{
+ Vector<int> intVector;
+ intVector.append(0);
+ intVector.append(1);
+ intVector.append(2);
+ intVector.append(3);
+
+ EXPECT_EQ(4u, intVector.size());
+ EXPECT_EQ(0, intVector[0]);
+ EXPECT_EQ(1, intVector[1]);
+ EXPECT_EQ(2, intVector[2]);
+ EXPECT_EQ(3, intVector[3]);
+
+ intVector.remove(2, 0);
+ EXPECT_EQ(4u, intVector.size());
+ EXPECT_EQ(2, intVector[2]);
+
+ intVector.remove(2, 1);
+ EXPECT_EQ(3u, intVector.size());
+ EXPECT_EQ(3, intVector[2]);
+
+ intVector.remove(0, 0);
+ EXPECT_EQ(3u, intVector.size());
+ EXPECT_EQ(0, intVector[0]);
+
+ intVector.remove(0);
+ EXPECT_EQ(2u, intVector.size());
+ EXPECT_EQ(1, intVector[0]);
+}
+
TEST(VectorTest, Iterator)
{
Vector<int> intVector;
« 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