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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 2796163002: Migrate WTF::HashCountedSet::add() to ::insert() (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 primitiveMember->insert(4, one); 2416 primitiveMember->insert(4, one);
2417 memberPrimitive->insert(one, 2); 2417 memberPrimitive->insert(one, 2);
2418 memberPrimitive->insert(two, 3); 2418 memberPrimitive->insert(two, 3);
2419 memberPrimitive->insert(three, 4); 2419 memberPrimitive->insert(three, 4);
2420 memberPrimitive->insert(four, 1); 2420 memberPrimitive->insert(four, 1);
2421 set2->insert(one); 2421 set2->insert(one);
2422 set2->insert(two); 2422 set2->insert(two);
2423 set2->insert(three); 2423 set2->insert(three);
2424 set2->insert(four); 2424 set2->insert(four);
2425 set->insert(oneB); 2425 set->insert(oneB);
2426 set3->add(oneB); 2426 set3->insert(oneB);
2427 set3->add(oneB); 2427 set3->insert(oneB);
2428 vector->push_back(oneB); 2428 vector->push_back(oneB);
2429 deque->push_back(oneB); 2429 deque->push_back(oneB);
2430 vector2->push_back(threeB); 2430 vector2->push_back(threeB);
2431 vector2->push_back(fourB); 2431 vector2->push_back(fourB);
2432 deque2->push_back(threeE); 2432 deque2->push_back(threeE);
2433 deque2->push_back(fourE); 2433 deque2->push_back(fourE);
2434 vectorWU->push_back(PairWrappedUnwrapped(&*oneC, 42)); 2434 vectorWU->push_back(PairWrappedUnwrapped(&*oneC, 42));
2435 dequeWU->push_back(PairWrappedUnwrapped(&*oneE, 42)); 2435 dequeWU->push_back(PairWrappedUnwrapped(&*oneE, 42));
2436 vectorWU2->push_back(PairWrappedUnwrapped(&*threeC, 43)); 2436 vectorWU2->push_back(PairWrappedUnwrapped(&*threeC, 43));
2437 vectorWU2->push_back(PairWrappedUnwrapped(&*fourC, 44)); 2437 vectorWU2->push_back(PairWrappedUnwrapped(&*fourC, 44));
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
2944 2944
2945 { 2945 {
2946 weakStrong->insert(IntWrapper::create(1), two); 2946 weakStrong->insert(IntWrapper::create(1), two);
2947 strongWeak->insert(two, IntWrapper::create(1)); 2947 strongWeak->insert(two, IntWrapper::create(1));
2948 weakWeak->insert(two, IntWrapper::create(42)); 2948 weakWeak->insert(two, IntWrapper::create(42));
2949 weakWeak->insert(IntWrapper::create(42), two); 2949 weakWeak->insert(IntWrapper::create(42), two);
2950 weakSet->insert(IntWrapper::create(0)); 2950 weakSet->insert(IntWrapper::create(0));
2951 weakSet->insert(two); 2951 weakSet->insert(two);
2952 weakSet->insert(keepNumbersAlive[0]); 2952 weakSet->insert(keepNumbersAlive[0]);
2953 weakSet->insert(keepNumbersAlive[1]); 2953 weakSet->insert(keepNumbersAlive[1]);
2954 weakCountedSet->add(IntWrapper::create(0)); 2954 weakCountedSet->insert(IntWrapper::create(0));
2955 weakCountedSet->add(two); 2955 weakCountedSet->insert(two);
2956 weakCountedSet->add(two); 2956 weakCountedSet->insert(two);
2957 weakCountedSet->add(two); 2957 weakCountedSet->insert(two);
2958 weakCountedSet->add(keepNumbersAlive[0]); 2958 weakCountedSet->insert(keepNumbersAlive[0]);
2959 weakCountedSet->add(keepNumbersAlive[1]); 2959 weakCountedSet->insert(keepNumbersAlive[1]);
2960 EXPECT_EQ(1u, weakStrong->size()); 2960 EXPECT_EQ(1u, weakStrong->size());
2961 EXPECT_EQ(1u, strongWeak->size()); 2961 EXPECT_EQ(1u, strongWeak->size());
2962 EXPECT_EQ(2u, weakWeak->size()); 2962 EXPECT_EQ(2u, weakWeak->size());
2963 EXPECT_EQ(4u, weakSet->size()); 2963 EXPECT_EQ(4u, weakSet->size());
2964 EXPECT_EQ(4u, weakCountedSet->size()); 2964 EXPECT_EQ(4u, weakCountedSet->size());
2965 EXPECT_EQ(3u, weakCountedSet->find(two)->value); 2965 EXPECT_EQ(3u, weakCountedSet->find(two)->value);
2966 weakCountedSet->remove(two); 2966 weakCountedSet->remove(two);
2967 EXPECT_EQ(2u, weakCountedSet->find(two)->value); 2967 EXPECT_EQ(2u, weakCountedSet->find(two)->value);
2968 } 2968 }
2969 2969
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 EXPECT_EQ(0u, weakWeak->size()); 3552 EXPECT_EQ(0u, weakWeak->size());
3553 EXPECT_EQ(0u, weakSet->size()); 3553 EXPECT_EQ(0u, weakSet->size());
3554 EXPECT_EQ(0u, weakOrderedSet->size()); 3554 EXPECT_EQ(0u, weakOrderedSet->size());
3555 } 3555 }
3556 } 3556 }
3557 } 3557 }
3558 3558
3559 TEST(HeapTest, HeapHashCountedSetToVector) { 3559 TEST(HeapTest, HeapHashCountedSetToVector) {
3560 HeapHashCountedSet<Member<IntWrapper>> set; 3560 HeapHashCountedSet<Member<IntWrapper>> set;
3561 HeapVector<Member<IntWrapper>> vector; 3561 HeapVector<Member<IntWrapper>> vector;
3562 set.add(new IntWrapper(1)); 3562 set.insert(new IntWrapper(1));
3563 set.add(new IntWrapper(1)); 3563 set.insert(new IntWrapper(1));
3564 set.add(new IntWrapper(2)); 3564 set.insert(new IntWrapper(2));
3565 3565
3566 copyToVector(set, vector); 3566 copyToVector(set, vector);
3567 EXPECT_EQ(3u, vector.size()); 3567 EXPECT_EQ(3u, vector.size());
3568 3568
3569 Vector<int> intVector; 3569 Vector<int> intVector;
3570 for (const auto& i : vector) 3570 for (const auto& i : vector)
3571 intVector.push_back(i->value()); 3571 intVector.push_back(i->value());
3572 std::sort(intVector.begin(), intVector.end()); 3572 std::sort(intVector.begin(), intVector.end());
3573 ASSERT_EQ(3u, intVector.size()); 3573 ASSERT_EQ(3u, intVector.size());
3574 EXPECT_EQ(1, intVector[0]); 3574 EXPECT_EQ(1, intVector[0]);
3575 EXPECT_EQ(1, intVector[1]); 3575 EXPECT_EQ(1, intVector[1]);
3576 EXPECT_EQ(2, intVector[2]); 3576 EXPECT_EQ(2, intVector[2]);
3577 } 3577 }
3578 3578
3579 TEST(HeapTest, WeakHeapHashCountedSetToVector) { 3579 TEST(HeapTest, WeakHeapHashCountedSetToVector) {
3580 HeapHashCountedSet<WeakMember<IntWrapper>> set; 3580 HeapHashCountedSet<WeakMember<IntWrapper>> set;
3581 HeapVector<Member<IntWrapper>> vector; 3581 HeapVector<Member<IntWrapper>> vector;
3582 set.add(new IntWrapper(1)); 3582 set.insert(new IntWrapper(1));
3583 set.add(new IntWrapper(1)); 3583 set.insert(new IntWrapper(1));
3584 set.add(new IntWrapper(2)); 3584 set.insert(new IntWrapper(2));
3585 3585
3586 copyToVector(set, vector); 3586 copyToVector(set, vector);
3587 EXPECT_LE(3u, vector.size()); 3587 EXPECT_LE(3u, vector.size());
3588 for (const auto& i : vector) 3588 for (const auto& i : vector)
3589 EXPECT_TRUE(i->value() == 1 || i->value() == 2); 3589 EXPECT_TRUE(i->value() == 1 || i->value() == 2);
3590 } 3590 }
3591 3591
3592 TEST(HeapTest, RefCountedGarbageCollected) { 3592 TEST(HeapTest, RefCountedGarbageCollected) {
3593 RefCountedAndGarbageCollected::s_destructorCalls = 0; 3593 RefCountedAndGarbageCollected::s_destructorCalls = 0;
3594 { 3594 {
(...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after
6345 "HeapVector"); 6345 "HeapVector");
6346 static_assert( 6346 static_assert(
6347 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, 6347 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value,
6348 "HeapDeque"); 6348 "HeapDeque");
6349 static_assert(WTF::IsGarbageCollectedType< 6349 static_assert(WTF::IsGarbageCollectedType<
6350 HeapTerminatedArray<Member<IntWrapper>>>::value, 6350 HeapTerminatedArray<Member<IntWrapper>>>::value,
6351 "HeapTerminatedArray"); 6351 "HeapTerminatedArray");
6352 } 6352 }
6353 6353
6354 } // namespace blink 6354 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698