Index: tests/MathTest.cpp |
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp |
index 1dd8223091e5914686caf3b6f50f31fff4abdbb2..a3e0b740e11e4018b4d50da506ac74b86b7f85f9 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)); |
+} |