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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 2250353002: Introduce copyToVector for HeapHashCountedSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-some-hash-counted-set-copy-to-vector
Patch Set: Created 4 years, 4 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
Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
index 328e00a9f544d521ccb5803c7254cbd47ac31bef..7236d23298e3a4beec1c5ed9321a2cbe4d451292 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -45,6 +45,7 @@
#include "wtf/HashTraits.h"
#include "wtf/LinkedHashSet.h"
#include "wtf/PtrUtil.h"
+#include <algorithm>
#include <memory>
namespace blink {
@@ -3853,6 +3854,41 @@ TEST(HeapTest, HeapWeakCollectionTypes)
}
}
+TEST(HeapTest, HeapHashCountedSetToVector)
+{
+ HeapHashCountedSet<Member<IntWrapper>> set;
+ HeapVector<Member<IntWrapper>> vector;
+ set.add(new IntWrapper(1));
+ set.add(new IntWrapper(1));
+ set.add(new IntWrapper(2));
+
+ copyToVector(set, vector);
+ EXPECT_EQ(3u, vector.size());
+
+ Vector<int> intVector;
+ for (const auto& i : vector)
+ intVector.append(i->value());
+ std::sort(intVector.begin(), intVector.end());
+ ASSERT_EQ(3u, intVector.size());
+ EXPECT_EQ(1, intVector[0]);
+ EXPECT_EQ(1, intVector[1]);
+ EXPECT_EQ(2, intVector[2]);
+}
+
+TEST(HeapTest, WeakHeapHashCountedSetToVector)
+{
+ HeapHashCountedSet<WeakMember<IntWrapper>> set;
+ HeapVector<Member<IntWrapper>> vector;
+ set.add(new IntWrapper(1));
+ set.add(new IntWrapper(1));
+ set.add(new IntWrapper(2));
+
+ copyToVector(set, vector);
+ EXPECT_LE(3u, vector.size());
+ for (const auto& i : vector)
+ EXPECT_TRUE(i->value() == 1 || i->value() == 2);
+}
+
TEST(HeapTest, RefCountedGarbageCollected)
{
RefCountedAndGarbageCollected::s_destructorCalls = 0;
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapAllocator.h ('k') | third_party/WebKit/Source/wtf/HashCountedSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698