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

Unified Diff: tests/Sk4xTest.cpp

Issue 964603002: Add sqrt() and rsqrt() to Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 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 | « src/core/Sk4x_sse.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Sk4xTest.cpp
diff --git a/tests/Sk4xTest.cpp b/tests/Sk4xTest.cpp
index 0985c3b2ff692b5090d2e4ea33299cf7867f91b3..23eaf6853e6bc7ddab62b44f1be51bd1b01f5a51 100644
--- a/tests/Sk4xTest.cpp
+++ b/tests/Sk4xTest.cpp
@@ -87,6 +87,18 @@ DEF_TEST(Sk4x_ImplicitPromotion, r) {
ASSERT_EQ(Sk4f(2,4,6,8), Sk4f(1,2,3,4).multiply(2.0f));
}
+DEF_TEST(Sk4x_Sqrt, r) {
+ Sk4f squares(4, 16, 25, 121),
+ roots(2, 4, 5, 11);
+ // .sqrt() should be pretty precise.
+ ASSERT_EQ(roots, squares.sqrt());
+
+ // .rsqrt() isn't so precise, but should be pretty close.
+ Sk4f error = roots.subtract(squares.multiply(squares.rsqrt()));
+ REPORTER_ASSERT(r, error.greaterThan(0.0f).allTrue());
+ REPORTER_ASSERT(r, error.lessThan(0.01f).allTrue());
+}
+
DEF_TEST(Sk4x_Comparison, r) {
ASSERT_EQ(Sk4f(1,2,3,4), Sk4f(1,2,3,4));
ASSERT_NE(Sk4f(4,3,2,1), Sk4f(1,2,3,4));
« no previous file with comments | « src/core/Sk4x_sse.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698