Index: Source/platform/graphics/ListContainerTest.cpp |
diff --git a/Source/platform/graphics/ListContainerTest.cpp b/Source/platform/graphics/ListContainerTest.cpp |
index b92b588bcb977fdb77a9bd1e13ba78e1e440cbbd..c6011c1b788493f7d395bde82ed570a3e5435657 100644 |
--- a/Source/platform/graphics/ListContainerTest.cpp |
+++ b/Source/platform/graphics/ListContainerTest.cpp |
@@ -853,6 +853,42 @@ TEST(ListContainerTest, AppendByMovingDoesNotDestruct) |
EXPECT_CALL(*mde1, Destruct()); |
} |
+TEST(ListContainerTest, AllocateWithoutConstructionDoesNotConstruct) |
+{ |
+ static int constructorCount = 0; |
+ class ConstructCounter : public SimpleDerivedElementConstructMagicNumberOne { |
+ public: |
+ ConstructCounter() : SimpleDerivedElementConstructMagicNumberOne() |
+ { |
+ constructorCount++; |
+ } |
+ }; |
+ |
+ ListContainer<ConstructCounter> list(kCurrentLargestDerivedElementSize); |
+ |
+ ConstructCounter* constructCounter1 = list.allocateWithoutConstruction<ConstructCounter>(); |
+ EXPECT_EQ(0, constructorCount); |
+ EXPECT_EQ(1u, list.size()); |
+ new (constructCounter1) ConstructCounter; |
+ EXPECT_EQ(1, constructorCount); |
+ list.allocateAndConstruct<ConstructCounter>(); |
+ EXPECT_EQ(2, constructorCount); |
+ EXPECT_EQ(2u, list.size()); |
+} |
+ |
+TEST(ListContainerTest, AppendByMovingReturnsMovedPointer) |
+{ |
+ ListContainer<SimpleDerivedElement> list1(kCurrentLargestDerivedElementSize); |
+ ListContainer<SimpleDerivedElement> list2(kCurrentLargestDerivedElementSize); |
+ SimpleDerivedElement* simpleElement = list1.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberOne>(); |
+ |
+ SimpleDerivedElement* movedElement1 = list2.appendByMoving(simpleElement); |
+ EXPECT_EQ(list2.back(), movedElement1); |
+ |
+ SimpleDerivedElement* movedElement2 = list1.appendByMoving(movedElement1); |
+ EXPECT_EQ(list1.back(), movedElement2); |
chrishtr
2015/06/29 17:19:16
Assert the pointers are not equal.
pdr.
2015/06/29 22:20:03
Done.
|
+} |
+ |
TEST(ListContainerTest, AppendByMovingReplacesSourceWithNewDerivedElement) |
{ |
ListContainer<SimpleDerivedElementConstructMagicNumberOne> list1(kCurrentLargestDerivedElementSize); |