aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-02-14 11:14:16 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-14 19:32:58 +0000
commit78c0c4c5a0bed8ac54542d2d378a0fc9ec8c034b (patch)
tree4759455e2d4e41a40755572bdca0cbfc36c99b85 /tests
parentc5aa2669df99f1faa341aa5f0d8ceb4c85eef185 (diff)
Remove SkSmallAllocator.
TBR=mtklein@google.com Change-Id: I375af12c5de4397a682c1946404282da95ad42ec Reviewed-on: https://skia-review.googlesource.com/8392 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/SmallAllocatorTest.cpp93
1 files changed, 0 insertions, 93 deletions
diff --git a/tests/SmallAllocatorTest.cpp b/tests/SmallAllocatorTest.cpp
deleted file mode 100644
index a5f45b1e8b..0000000000
--- a/tests/SmallAllocatorTest.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2014 Google, Inc
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSmallAllocator.h"
-#include "SkTypes.h"
-#include "Test.h"
-
-class CountingClass {
-public:
- CountingClass() {
- kCount++;
- }
-
- ~CountingClass() {
- kCount--;
- }
-
- static int GetCount() { return kCount; }
-
-private:
- static int kCount;
-};
-
-int CountingClass::kCount;
-
-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) {
- CountingClass* c = alloc.template createT<CountingClass>();
- REPORTER_ASSERT(reporter, c != nullptr);
- REPORTER_ASSERT(reporter, CountingClass::GetCount() == static_cast<int>(i+1));
- }
- }
- REPORTER_ASSERT(reporter, CountingClass::GetCount() == 0);
-}
-
-// Tests that ensure that the destructor is called, whether the objects
-// 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).
- test_allocator<5, 20>(reporter);
- test_allocator<10, 40>(reporter);
- test_allocator<20, 80>(reporter);
-
- // 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);
-}
-
-class Dummy {
-};
-
-class DummyContainer {
-public:
- explicit DummyContainer(Dummy* d)
- :fDummy(d)
- {}
-
- Dummy* getDummy() const { return fDummy; }
-
-private:
- Dummy* fDummy;
-};
-
-// Test that using a createT with a constructor taking a pointer as a
-// parameter works as expected.
-DEF_TEST(SmallAllocator_pointer, reporter) {
- SkSmallAllocator<1, 8> alloc;
- Dummy d;
- DummyContainer* container = alloc.createT<DummyContainer>(&d);
- 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.createWithIniter(
- sizeof(DummyContainer),
- [&](void* storage) {
- return new (storage) DummyContainer(&d);
- });
- REPORTER_ASSERT(reporter, container != nullptr);
- REPORTER_ASSERT(reporter, container->getDummy() == &d);
-}