aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-01-11 21:16:11 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-11 21:47:44 +0000
commit8d80bb5f20d899fb7da58b0be0c1218db420891a (patch)
tree6d6df7e6119e33ee698e481a9f750463a3f3e00c /tests
parentd1c8e56423f4d1a879f3a7bcd24e2725d9b690a7 (diff)
Revert "Introduce SkArenaAlloc - should be fast for POD types and RAII for types with dtors."
This reverts commit 6ff51aedda6f3b4873c292d7e03e47ad656543f8. Reason for revert: breaks win2k8 and PDFium Change-Id: Ib1e2db8e523d5d321836ce00e3773def3db8be2f Reviewed-on: https://skia-review.googlesource.com/6898 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/FixedAllocTest.cpp90
1 files changed, 1 insertions, 89 deletions
diff --git a/tests/FixedAllocTest.cpp b/tests/FixedAllocTest.cpp
index 5c36b537fa..0a00f00935 100644
--- a/tests/FixedAllocTest.cpp
+++ b/tests/FixedAllocTest.cpp
@@ -13,8 +13,7 @@ namespace {
static int created, destroyed;
struct Foo {
- Foo() : x(-2), y(-3.0f) { created++; }
- Foo(int X, float Y) : x(X), y(Y) { created++; }
+ Foo(int X, float Y) : x(X), y(Y) { created++; }
~Foo() { destroyed++; }
int x;
@@ -112,90 +111,3 @@ DEF_TEST(FallbackAlloc, r) {
REPORTER_ASSERT(r, !in_buf(big));
REPORTER_ASSERT(r, !in_buf(smallB));
}
-
-struct WithDtor {
- ~WithDtor() { }
-};
-
-DEF_TEST(ArenaAlloc, r) {
- {
- created = 0;
- destroyed = 0;
-
- SkArenaAlloc arena{nullptr, 0};
- REPORTER_ASSERT(r, *arena.make<int>(3) == 3);
- Foo* foo = arena.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, foo->x == 3);
- REPORTER_ASSERT(r, foo->y == 4.0f);
- REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.makeArrayDefault<int>(10);
- int* zeroed = arena.makeArray<int>(10);
- for (int i = 0; i < 10; i++) {
- REPORTER_ASSERT(r, zeroed[i] == 0);
- }
- Foo* fooArray = arena.makeArrayDefault<Foo>(10);
- REPORTER_ASSERT(r, fooArray[3].x == -2);
- REPORTER_ASSERT(r, fooArray[4].y == -3.0f);
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.make<typename std::aligned_storage<10,8>::type>();
- }
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 11);
-
- {
- created = 0;
- destroyed = 0;
- char block[1024];
- SkArenaAlloc arena{block};
-
- REPORTER_ASSERT(r, *arena.make<int>(3) == 3);
- Foo* foo = arena.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, foo->x == 3);
- REPORTER_ASSERT(r, foo->y == 4.0f);
- REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.makeArrayDefault<int>(10);
- int* zeroed = arena.makeArray<int>(10);
- for (int i = 0; i < 10; i++) {
- REPORTER_ASSERT(r, zeroed[i] == 0);
- }
- Foo* fooArray = arena.makeArrayDefault<Foo>(10);
- REPORTER_ASSERT(r, fooArray[3].x == -2);
- REPORTER_ASSERT(r, fooArray[4].y == -3.0f);
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.make<typename std::aligned_storage<10,8>::type>();
- }
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 11);
-
- {
- created = 0;
- destroyed = 0;
- std::unique_ptr<char[]> block{new char[1024]};
- SkArenaAlloc arena{block.get(), 1024};
-
- REPORTER_ASSERT(r, *arena.make<int>(3) == 3);
- Foo* foo = arena.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, foo->x == 3);
- REPORTER_ASSERT(r, foo->y == 4.0f);
- REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.makeArrayDefault<int>(10);
- int* zeroed = arena.makeArray<int>(10);
- for (int i = 0; i < 10; i++) {
- REPORTER_ASSERT(r, zeroed[i] == 0);
- }
- Foo* fooArray = arena.makeArrayDefault<Foo>(10);
- REPORTER_ASSERT(r, fooArray[3].x == -2);
- REPORTER_ASSERT(r, fooArray[4].y == -3.0f);
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 0);
- arena.make<typename std::aligned_storage<10,8>::type>();
- }
- REPORTER_ASSERT(r, created == 11);
- REPORTER_ASSERT(r, destroyed == 11);
-
-}