aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ScaleToSidesTest.cpp
blob: 60e82be52951201b54143f3a3a997d3cd55ad2c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
                    }
                }
            }
        }
    }
}