Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: tests/MathTest.cpp

Issue 2368293002: My take on SkAlign changes. (Closed)
Patch Set: also test SkAlign(ptr) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
+}
« no previous file with comments | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698