diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-12-05 15:04:29 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-09 10:49:28 +0100 |
commit | af6588f8d723931a298c995fa97259bb7f7deb55 (patch) | |
tree | 060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp | |
parent | 2fff84d821cc7b1c785f6404e0f8091333283e74 (diff) |
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp b/chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp index 41067dc12c4..a1f6a66f836 100644 --- a/chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp +++ b/chromium/third_party/WebKit/Source/wtf/ListHashSetTest.cpp @@ -265,7 +265,7 @@ int DummyRefCounted::m_refInvokesCount = 0; template<typename Set> void withRefPtr() { - bool isDeleted; + bool isDeleted = false; DummyRefCounted::m_refInvokesCount = 0; RefPtr<DummyRefCounted> ptr = adoptRef(new DummyRefCounted(isDeleted)); EXPECT_EQ(0, DummyRefCounted::m_refInvokesCount); @@ -656,4 +656,66 @@ TEST(ListHashSetTest, WithOwnPtr) EXPECT_EQ(ptr2, ownPtr2); } +template<typename Set> +void swapTestHelper() +{ + int num = 10; + Set set0; + Set set1; + Set set2; + for (int i = 0; i < num; ++i) { + set1.add(i + 1); + set2.add(num - i); + } + + typename Set::iterator it1 = set1.begin(); + typename Set::iterator it2 = set2.begin(); + for (int i = 0; i < num; ++i, ++it1, ++it2) { + EXPECT_EQ(*it1, i + 1); + EXPECT_EQ(*it2, num - i); + } + EXPECT_EQ(set0.begin(), set0.end()); + EXPECT_EQ(it1, set1.end()); + EXPECT_EQ(it2, set2.end()); + + // Shift sets: 2->1, 1->0, 0->2 + set1.swap(set2); // Swap with non-empty sets. + set0.swap(set2); // Swap with an empty set. + + it1 = set0.begin(); + it2 = set1.begin(); + for (int i = 0; i < num; ++i, ++it1, ++it2) { + EXPECT_EQ(*it1, i + 1); + EXPECT_EQ(*it2, num - i); + } + EXPECT_EQ(it1, set0.end()); + EXPECT_EQ(it2, set1.end()); + EXPECT_EQ(set2.begin(), set2.end()); + + int removedIndex = num >> 1; + set0.remove(removedIndex + 1); + set1.remove(num - removedIndex); + + it1 = set0.begin(); + it2 = set1.begin(); + for (int i = 0; i < num; ++i, ++it1, ++it2) { + if (i == removedIndex) + ++i; + EXPECT_EQ(*it1, i + 1); + EXPECT_EQ(*it2, num - i); + } + EXPECT_EQ(it1, set0.end()); + EXPECT_EQ(it2, set1.end()); +} + +TEST(ListHashSetTest, Swap) +{ + swapTestHelper<ListHashSet<int> >(); +} + +TEST(LinkedHashSetTest, Swap) +{ + swapTestHelper<LinkedHashSet<int> >(); +} + } // namespace |