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

Unified Diff: third_party/WebKit/Source/wtf/VectorTest.cpp

Issue 2365533003: Add WTF::Vector::emplaceAppend() (Closed)
Patch Set: Created 4 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 aa7509b11586e4ed79b13f43e3ca1f5165a11aa1..1bbc36191ad607f72bb4db0c3b230dadd81fc644 100644
--- a/third_party/WebKit/Source/wtf/VectorTest.cpp
+++ b/third_party/WebKit/Source/wtf/VectorTest.cpp
@@ -698,6 +698,25 @@ TEST(VectorTest, Optional)
EXPECT_EQ(3u, vector->size());
}
+TEST(VectorTest, emplaceAppend)
+{
+ struct Item {
+ Item(int value1, int value2) : value1(value1), value2(value2) {}
+ int value1;
+ int value2;
+ };
+
+ Vector<Item> vector;
+ vector.emplaceAppend(1, 2);
+ vector.emplaceAppend(3, 4);
+
+ EXPECT_EQ(2u, vector.size());
+ EXPECT_EQ(1, vector[0].value1);
+ EXPECT_EQ(2, vector[0].value2);
+ EXPECT_EQ(3, vector[1].value1);
+ EXPECT_EQ(4, vector[1].value2);
+}
+
static_assert(VectorTraits<int>::canCopyWithMemcpy, "int should be copied with memcopy.");
static_assert(VectorTraits<char>::canCopyWithMemcpy, "char should be copied with memcpy.");
static_assert(VectorTraits<LChar>::canCopyWithMemcpy, "LChar should be copied with memcpy.");
« 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