blob: 60e82be52951201b54143f3a3a997d3cd55ad2c4 [file] [log] [blame]
herb7cf12dd2016-01-11 08:08:56 -08001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "SkScaleToSides.h"
9
10#include <cfloat>
11#include "Test.h"
12
13DEF_TEST(ScaleToSides, reporter) {
14 float interestingValues[] = {
15 0.0f,
16 0.5f,
17 1.0f,
18 2.0f,
19 3.0f,
20 33.0f,
21 33554430.0f,
22 33554431.0f,
23 33554464.0f,
24 333333332.0f,
25 333333333.0f,
26 333333334.0f,
27 FLT_MAX,
28 FLT_EPSILON,
29 FLT_MIN
30 };
31
32 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues);
33
34 for (int i = 0; i < numInterestingValues; i++) {
35 for (int j = 0; j < numInterestingValues; j++) {
36 for (int k = 0; k < numInterestingValues; k++) {
37 float radius1 = interestingValues[i];
38 float radius2 = interestingValues[j];
39 float width = interestingValues[k];
40 if (width > 0.0f) {
41 double scale = (double)width / ((double)radius1 + (double)radius2);
42 if (scale < 1.0) {
43 ScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
44 }
45 }
46 }
47 }
48 }
49}