aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-01-13 17:34:33 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-16 17:01:57 +0000
commitac04fef619ad3939a25e66bdaef6f6b1e7f5ca50 (patch)
treed30efcbac91ac1a4b434d910a64487e70efbde0d /tests
parent26e73c057755df4fbffeee372be98e430867034d (diff)
Remove SkFallbackAlloc and SkFixedAlloc.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN;skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN TBR=reed@google.com Change-Id: I1000dc9ed8ad65b249798759d9af99f47fc237d2 Reviewed-on: https://skia-review.googlesource.com/6809 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ArenaAllocTest.cpp (renamed from tests/FixedAllocTest.cpp)88
1 files changed, 1 insertions, 87 deletions
diff --git a/tests/FixedAllocTest.cpp b/tests/ArenaAllocTest.cpp
index 75bc232b4b..647ea25283 100644
--- a/tests/FixedAllocTest.cpp
+++ b/tests/ArenaAllocTest.cpp
@@ -6,7 +6,7 @@
*/
#include "Test.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
namespace {
@@ -28,91 +28,6 @@ namespace {
}
-DEF_TEST(FixedAlloc, r) {
- // Basic mechanics.
- {
- uint8_t buf[128];
- SkFixedAlloc fa(buf, sizeof(buf));
-
- Foo* foo = fa.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, foo);
- REPORTER_ASSERT(r, foo->x == 3);
- REPORTER_ASSERT(r, foo->y == 4.0f);
- REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
-
- Foo* bar = fa.make<Foo>(8, 1.0f);
- REPORTER_ASSERT(r, bar);
- REPORTER_ASSERT(r, bar->x == 8);
- REPORTER_ASSERT(r, bar->y == 1.0f);
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 0);
-
- fa.undo();
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 1);
- }
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 2);
-
- {
- // Test alignment gurantees.
- uint8_t buf[64];
- SkFixedAlloc fa(buf+3, sizeof(buf)-3);
-
- Foo* foo = fa.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, SkIsAlign4((uintptr_t)foo));
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 2);
-
- // Might as well test reset() while we're at it.
- fa.reset();
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
- }
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
-}
-
-DEF_TEST(FallbackAlloc, r) {
- // SkFixedAlloc will eventually fail when it runs out of space in its buffer.
- int buf[32];
- SkFixedAlloc fixed(buf, sizeof(buf));
- bool fixed_failed = false;
- for (int i = 0; i < 32; i++) {
- // (Remember, there is some overhead to each make() call.)
- fixed_failed = fixed_failed || (fixed.make<int>(i) == nullptr);
- }
- REPORTER_ASSERT(r, fixed_failed);
-
-
- // SkFallbackAlloc will always succeed, using the heap as required.
- fixed.reset();
- SkFallbackAlloc fallback(&fixed);
-
- bool fallback_failed = false;
- for (int i = 0; i < 32; i++) {
- fallback_failed = fallback_failed || (fallback.make<int>(i) == nullptr);
- }
- REPORTER_ASSERT(r, !fallback_failed);
-
-
- // Test small, big, small allocations to make sure once we go to the heap we stay there.
- fallback.reset();
- auto smallA = fallback.make<int>(2);
- auto big = fallback.make<Big>();
- auto smallB = fallback.make<int>(3);
-
- auto in_buf = [&](void* ptr) {
- return (uintptr_t)(buf+0 ) <= (uintptr_t)ptr
- && (uintptr_t)(buf+32) > (uintptr_t)ptr;
- };
-
- REPORTER_ASSERT(r, in_buf(smallA));
- REPORTER_ASSERT(r, !in_buf(big));
- REPORTER_ASSERT(r, !in_buf(smallB));
-}
-
struct WithDtor {
~WithDtor() { }
};
@@ -198,5 +113,4 @@ DEF_TEST(ArenaAlloc, r) {
}
REPORTER_ASSERT(r, created == 11);
REPORTER_ASSERT(r, destroyed == 11);
-
}