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

Unified Diff: tests/PointTest.cpp

Issue 60083014: Add sk_float_rsqrt with SSE + NEON fast paths. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: test Created 7 years, 1 month 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/SkPoint.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PointTest.cpp
diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp
index 1255a8c65df11c6b8a944bcb0e3adecf86d61bc6..9f91c47c1c6d9d7285b326c81e1a3cf81c1600ec 100644
--- a/tests/PointTest.cpp
+++ b/tests/PointTest.cpp
@@ -117,7 +117,8 @@ static void test_underflow(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, pt == copy); // pt is unchanged
}
-static void PointTest(skiatest::Reporter* reporter) {
+#include "TestClassDef.h"
+DEF_TEST(Point, reporter) {
test_casts(reporter);
static const struct {
@@ -137,5 +138,22 @@ static void PointTest(skiatest::Reporter* reporter) {
test_overflow(reporter);
}
-#include "TestClassDef.h"
-DEFINE_TESTCLASS("Point", PointTestClass, PointTest)
+DEF_TEST(Point_setLengthFast, reporter) {
+ // Scale a (1,1) point to a bunch of different lengths,
+ // making sure the slow and fast paths are within 0.1%.
+ const float tests[] = { 1.0f, 0.0f, 1.0e-37f, 3.4e38f, 42.0f, 0.00012f };
+
+ const SkPoint kOne = {1.0f, 1.0f};
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(tests); i++) {
+ SkPoint slow = kOne, fast = kOne;
+
+ slow.setLength(tests[i]);
+ fast.setLengthFast(tests[i]);
+
+ if (slow.length() < FLT_MIN && fast.length() < FLT_MIN) continue;
+
+ SkScalar ratio = slow.length() / fast.length();
+ REPORTER_ASSERT(reporter, ratio > 0.999f);
+ REPORTER_ASSERT(reporter, ratio < 1.001f);
+ }
+}
« no previous file with comments | « src/core/SkPoint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698