aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-02-06 13:03:49 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-06 19:27:14 +0000
commit68521702299e092211cf7085e8544556ea9dffc7 (patch)
tree9decc8ccb6ac104bb9a3e790e483c8bd94539345 /tests
parente1d9cb82bf9004eb05831f34bb3e9e708ae0617f (diff)
Add sk_sp make variant to SkArenaAlloc.
R=bungeman@google.com BUG=skia: Change-Id: Iec588cb6946f0230ff3d3ec46499c365aa6b8d09 Reviewed-on: https://skia-review.googlesource.com/8067 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ArenaAllocTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ArenaAllocTest.cpp b/tests/ArenaAllocTest.cpp
index 0836b0c49f..c27c202bdb 100644
--- a/tests/ArenaAllocTest.cpp
+++ b/tests/ArenaAllocTest.cpp
@@ -7,6 +7,7 @@
#include "Test.h"
#include "SkArenaAlloc.h"
+#include "SkRefCnt.h"
namespace {
@@ -46,6 +47,15 @@ namespace {
Node* start;
};
+ struct FooRefCnt : public SkRefCnt {
+ FooRefCnt() : x(-2), y(-3.0f) { created++; }
+ FooRefCnt(int X, float Y) : x(X), y(Y) { created++; }
+ ~FooRefCnt() { destroyed++; }
+
+ int x;
+ float y;
+ };
+
}
struct WithDtor {
@@ -159,4 +169,19 @@ DEF_TEST(ArenaAlloc, r) {
REPORTER_ASSERT(r, created == 128);
REPORTER_ASSERT(r, destroyed == 128);
+
+ {
+ created = 0;
+ destroyed = 0;
+ char storage[64];
+ SkArenaAlloc arena{storage};
+
+ sk_sp<FooRefCnt> f = arena.makeSkSp<FooRefCnt>(4, 5.0f);
+ REPORTER_ASSERT(r, f->x == 4);
+ REPORTER_ASSERT(r, f->y == 5.0f);
+ REPORTER_ASSERT(r, created == 1);
+ REPORTER_ASSERT(r, destroyed == 0);
+ }
+ REPORTER_ASSERT(r, created == 1);
+ REPORTER_ASSERT(r, destroyed == 1);
}