aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/MathTest.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-09-26 10:31:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-26 10:31:12 -0700
commite1a5f4e292384046678edc5c1e360b3e13dc118c (patch)
tree15f6e79d89eb108bf4f39353f5bd5b4508818828 /tests/MathTest.cpp
parent3948a1bf18c246225f6aa11006e94bb3d396eb62 (diff)
My take on SkAlign changes.
Like the other change, it makes SkAlignN(x) macros work for pointers, and makes the macros themselves just syntax sugar for SkAlign<N>(x). We can still decide if we want to sed away the macros independently. This just does it in a somewhat less repetitive way, and adds some tests. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2368293002 No public API changes. TBR=reed@google.com Review-Url: https://codereview.chromium.org/2368293002
Diffstat (limited to 'tests/MathTest.cpp')
-rw-r--r--tests/MathTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 1dd8223091..a3e0b740e1 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -679,3 +679,21 @@ DEF_TEST(divmod_s32, r) {
DEF_TEST(divmod_s64, r) {
test_divmod<int64_t>(r);
}
+
+DEF_TEST(SkAlign, r) {
+ int x = 6;
+ REPORTER_ASSERT(r, SkIsAlign2(x));
+ REPORTER_ASSERT(r, !SkIsAlign4(x));
+ x = SkAlign4(x);
+ REPORTER_ASSERT(r, SkIsAlign2(x));
+ REPORTER_ASSERT(r, SkIsAlign4(x));
+
+ auto p = (char*)&x;
+ REPORTER_ASSERT(r, SkIsAlign2(p));
+ REPORTER_ASSERT(r, SkIsAlign4(p));
+ p += 2;
+ REPORTER_ASSERT(r, SkIsAlign2(p));
+ REPORTER_ASSERT(r, !SkIsAlign4(p));
+ p = SkAlign4(p);
+ REPORTER_ASSERT(r, p == (char*)(&x+1));
+}