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

Unified Diff: tests/SmallAllocatorTest.cpp

Issue 2485853005: Revert of Make SkSmallAllocator obey the RAII invariants and be expandable (Closed)
Patch Set: Created 4 years, 1 month 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 | « tests/LayerDrawLooperTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SmallAllocatorTest.cpp
diff --git a/tests/SmallAllocatorTest.cpp b/tests/SmallAllocatorTest.cpp
index d8cbe9cc4e51ad8abb20326ce2791ecedb191532..774e0c9e8982906f09def08548e98b2145ce1cf8 100644
--- a/tests/SmallAllocatorTest.cpp
+++ b/tests/SmallAllocatorTest.cpp
@@ -30,7 +30,7 @@
template<uint32_t kMaxObjects, size_t kBytes> void test_allocator(skiatest::Reporter* reporter) {
{
SkSmallAllocator<kMaxObjects, kBytes> alloc;
- for (uint32_t i = 0; i < kMaxObjects + 1; ++i) {
+ for (uint32_t i = 0; i < kMaxObjects; ++i) {
CountingClass* c = alloc.template createT<CountingClass>();
REPORTER_ASSERT(reporter, c != nullptr);
REPORTER_ASSERT(reporter, CountingClass::GetCount() == static_cast<int>(i+1));
@@ -43,15 +43,18 @@
// were created in fStorage or on the heap.
DEF_TEST(SmallAllocator_destructor, reporter) {
// Four times as many bytes as objects will never require any heap
- // allocations (since SkAlign4(sizeof(CountingClass)) == 4).
+ // allocations (since SkAlign4(sizeof(CountingClass)) == 4 and the allocator
+ // will stop once it reaches kMaxObjects).
test_allocator<5, 20>(reporter);
test_allocator<10, 40>(reporter);
test_allocator<20, 80>(reporter);
+#ifndef SK_DEBUG
// Allowing less bytes than objects means some will be allocated on the
// heap. Don't run these in debug where we assert.
test_allocator<50, 20>(reporter);
test_allocator<100, 20>(reporter);
+#endif
}
class Dummy {
@@ -78,16 +81,3 @@
REPORTER_ASSERT(reporter, container != nullptr);
REPORTER_ASSERT(reporter, container->getDummy() == &d);
}
-
-// Test that using a createWithIniterT works as expected.
-DEF_TEST(SmallAllocator_initer, reporter) {
- SkSmallAllocator<1, 8> alloc;
- Dummy d;
- DummyContainer* container = alloc.createWithIniterT<DummyContainer>(
- sizeof(DummyContainer),
- [&](void* storage) {
- return new (storage) DummyContainer(&d);
- });
- REPORTER_ASSERT(reporter, container != nullptr);
- REPORTER_ASSERT(reporter, container->getDummy() == &d);
-}
« no previous file with comments | « tests/LayerDrawLooperTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698