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

Unified Diff: Source/platform/graphics/ListContainerTest.cpp

Issue 1207773003: Add ListContainer::swap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « Source/platform/graphics/ListContainer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ListContainerTest.cpp
diff --git a/Source/platform/graphics/ListContainerTest.cpp b/Source/platform/graphics/ListContainerTest.cpp
index 95d644edd07d509aa62ab2c37a2fec5e24e8889b..9c0bf00d569c0afc9623921f460fbaed686a7cc4 100644
--- a/Source/platform/graphics/ListContainerTest.cpp
+++ b/Source/platform/graphics/ListContainerTest.cpp
@@ -939,5 +939,33 @@ TEST(ListContainerTest, AppendByMovingLongAndSimpleDerivedElements)
EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list.back()->getValue());
}
+TEST(ListContainerTest, Swap)
+{
+ ListContainer<SimpleDerivedElement> list1(kCurrentLargestDerivedElementSize);
+ list1.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberOne>();
+ ListContainer<SimpleDerivedElement> list2(kCurrentLargestDerivedElementSize);
+ list2.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberTwo>();
+ list2.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberTwo>();
+
+ SimpleDerivedElement* preSwapList1Front = list1.front();
+
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list1.front()->getValue());
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list2.front()->getValue());
chrishtr 2015/06/24 18:12:28 same comment
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list2.back()->getValue());
+ EXPECT_EQ(1u, list1.size());
+ EXPECT_EQ(2u, list2.size());
+
+ list2.swap(list1);
+
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list1.front()->getValue());
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list1.back()->getValue());
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list2.front()->getValue());
+ EXPECT_EQ(2u, list1.size());
+ EXPECT_EQ(1u, list2.size());
+
+ // Ensure pointers are still valid after swapping.
+ EXPECT_EQ(preSwapList1Front, list2.front());
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « Source/platform/graphics/ListContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698