aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ScaleToSidesTest.cpp
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-01-11 08:08:56 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-11 08:08:56 -0800
commit7cf12ddb8c1c2cf7a0eec63439148cc6b2bc104a (patch)
tree8dee486021054106d79f39b071431dfc3fac2773 /tests/ScaleToSidesTest.cpp
parent8bae7c537ae77302a61a7fa5b990ca394710db32 (diff)
Fix radii calculation code to handle large radii.
Diffstat (limited to 'tests/ScaleToSidesTest.cpp')
-rw-r--r--tests/ScaleToSidesTest.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/ScaleToSidesTest.cpp b/tests/ScaleToSidesTest.cpp
new file mode 100644
index 0000000000..60e82be529
--- /dev/null
+++ b/tests/ScaleToSidesTest.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkScaleToSides.h"
+
+#include <cfloat>
+#include "Test.h"
+
+DEF_TEST(ScaleToSides, reporter) {
+ float interestingValues[] = {
+ 0.0f,
+ 0.5f,
+ 1.0f,
+ 2.0f,
+ 3.0f,
+ 33.0f,
+ 33554430.0f,
+ 33554431.0f,
+ 33554464.0f,
+ 333333332.0f,
+ 333333333.0f,
+ 333333334.0f,
+ FLT_MAX,
+ FLT_EPSILON,
+ FLT_MIN
+ };
+
+ int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues);
+
+ for (int i = 0; i < numInterestingValues; i++) {
+ for (int j = 0; j < numInterestingValues; j++) {
+ for (int k = 0; k < numInterestingValues; k++) {
+ float radius1 = interestingValues[i];
+ float radius2 = interestingValues[j];
+ float width = interestingValues[k];
+ if (width > 0.0f) {
+ double scale = (double)width / ((double)radius1 + (double)radius2);
+ if (scale < 1.0) {
+ ScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
+ }
+ }
+ }
+ }
+ }
+}