aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-03-06 17:18:47 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-08 20:06:15 +0000
commit3139de39d7adc263555e063300f0a5e7b7a86d11 (patch)
treebc9fd40c48d384a0821e324fc657f6eb39812a9e /tests
parent7dd57b6a936af923a031f21c4ca9dc1031742473 (diff)
Remove SkChunckAlloc
Change-Id: Ia400dd2d8aa398cf53852acd71c4a45228752496 Reviewed-on: https://skia-review.googlesource.com/9328 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/MemsetTest.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/tests/MemsetTest.cpp b/tests/MemsetTest.cpp
index fb5a337738..b68844c866 100644
--- a/tests/MemsetTest.cpp
+++ b/tests/MemsetTest.cpp
@@ -5,98 +5,10 @@
* found in the LICENSE file.
*/
-#include "SkChunkAlloc.h"
#include "SkRandom.h"
#include "SkUtils.h"
#include "Test.h"
-static void check_alloc(skiatest::Reporter* reporter, const SkChunkAlloc& alloc,
- size_t capacity, size_t used, int numBlocks) {
- REPORTER_ASSERT(reporter, alloc.totalCapacity() >= capacity);
- REPORTER_ASSERT(reporter, alloc.totalUsed() == used);
- SkDEBUGCODE(REPORTER_ASSERT(reporter, alloc.blockCount() == numBlocks);)
-}
-
-static void* simple_alloc(skiatest::Reporter* reporter, SkChunkAlloc* alloc, size_t size) {
- void* ptr = alloc->allocThrow(size);
- check_alloc(reporter, *alloc, size, size, 1);
- REPORTER_ASSERT(reporter, alloc->contains(ptr));
- return ptr;
-}
-
-static void check_alloc_alignment(skiatest::Reporter* reporter,
- SkChunkAlloc* alloc, size_t size) {
- const size_t kAlignment = 8;
- void* ptr = alloc->allocThrow(size);
- REPORTER_ASSERT(reporter, ptr != nullptr);
- REPORTER_ASSERT(reporter, (size_t)ptr % kAlignment == 0);
-}
-
-static void test_chunkalloc(skiatest::Reporter* reporter) {
- static const size_t kMin = 1024;
- SkChunkAlloc alloc(kMin);
-
- //------------------------------------------------------------------------
- // check empty
- check_alloc(reporter, alloc, 0, 0, 0);
- REPORTER_ASSERT(reporter, !alloc.contains(nullptr));
- REPORTER_ASSERT(reporter, !alloc.contains(reporter));
-
- // reset on empty allocator
- alloc.reset();
- check_alloc(reporter, alloc, 0, 0, 0);
-
- // rewind on empty allocator
- alloc.rewind();
- check_alloc(reporter, alloc, 0, 0, 0);
-
- //------------------------------------------------------------------------
- // test reset when something is allocated
- size_t size = kMin >> 1;
- void* ptr = simple_alloc(reporter, &alloc, size);
-
- alloc.reset();
- check_alloc(reporter, alloc, 0, 0, 0);
- REPORTER_ASSERT(reporter, !alloc.contains(ptr));
-
- //------------------------------------------------------------------------
- // test rewind when something is allocated
- ptr = simple_alloc(reporter, &alloc, size);
-
- alloc.rewind();
- check_alloc(reporter, alloc, size, 0, 1);
- REPORTER_ASSERT(reporter, !alloc.contains(ptr));
-
- // use the available block
- ptr = simple_alloc(reporter, &alloc, size);
- alloc.reset();
-
- //------------------------------------------------------------------------
- // test out allocating a second block
- ptr = simple_alloc(reporter, &alloc, size);
-
- ptr = alloc.allocThrow(kMin);
- check_alloc(reporter, alloc, 2*kMin, size+kMin, 2);
- REPORTER_ASSERT(reporter, alloc.contains(ptr));
-
- //------------------------------------------------------------------------
- // test out unalloc
- size_t freed = alloc.unalloc(ptr);
- REPORTER_ASSERT(reporter, freed == kMin);
- check_alloc(reporter, alloc, 2*kMin, size, 2);
- REPORTER_ASSERT(reporter, !alloc.contains(ptr));
-
- //------------------------------------------------------------------------
- // test the alignment
- alloc.reset();
- SkRandom rand;
- for (int i = 0; i < 1000; i++) {
- check_alloc_alignment(reporter, &alloc, rand.nextU16());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
static void set_zero(void* dst, size_t bytes) {
char* ptr = (char*)dst;
for (size_t i = 0; i < bytes; ++i) {
@@ -174,6 +86,4 @@ static void test_32(skiatest::Reporter* reporter) {
DEF_TEST(Memset, reporter) {
test_16(reporter);
test_32(reporter);
-
- test_chunkalloc(reporter);
}