~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to tests/unit/tst_components/tst_math_utils.qml

  • Committer: Zsombor Egri
  • Date: 2015-11-20 16:37:59 UTC
  • mfrom: (1662.2.62 staging)
  • Revision ID: zsombor.egri@canonical.com-20151120163759-8p94jar0o53nbu95
staging sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        compare(clamped, maxValue, "clamped value not within range")
85
85
    }
86
86
 
 
87
    function test_clamp_positive_lower_switched() {
 
88
        var minValue = 42
 
89
        var maxValue = 9
 
90
        var clampValue = -7
 
91
 
 
92
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
93
 
 
94
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
95
        compare(clamped, maxValue, "clamped value not within range")
 
96
    }
 
97
 
 
98
    function test_clamp_positive_greater_switched() {
 
99
        var minValue = 42
 
100
        var maxValue = 9
 
101
        var clampValue = 111
 
102
 
 
103
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
104
 
 
105
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
106
        compare(clamped, minValue, "clamped value not within range")
 
107
    }
 
108
 
 
109
    function test_clamp_positive_within_switched() {
 
110
        var minValue = 53
 
111
        var maxValue = 9
 
112
        var clampValue = 42
 
113
 
 
114
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
115
 
 
116
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
117
        compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
 
118
    }
 
119
 
 
120
    function test_clamp_positive_on_border_switched() {
 
121
        var minValue = 42
 
122
        var maxValue = 9
 
123
        var clampValue = 9
 
124
 
 
125
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
126
 
 
127
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
128
        compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
 
129
    }
 
130
 
 
131
    function test_clamp_negative_lower_switched() {
 
132
        var minValue = -9
 
133
        var maxValue = -42
 
134
        var clampValue = -50
 
135
 
 
136
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
137
 
 
138
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
139
        compare(clamped, maxValue, "clamped value not within range")
 
140
    }
 
141
 
 
142
    function test_clamp_negative_greater_switched() {
 
143
        var minValue = -9
 
144
        var maxValue = -42
 
145
        var clampValue = 50
 
146
 
 
147
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
148
 
 
149
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
150
        compare(clamped, minValue, "clamped value not within range")
 
151
    }
 
152
 
 
153
    function test_clamp_postive_and_negative_greater_switched() {
 
154
        var minValue = 9
 
155
        var maxValue = -42
 
156
        var clampValue = 50
 
157
 
 
158
        ignoreWarning("MathUtils.clamp, min value should not be bigger than the max value")
 
159
 
 
160
        var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
 
161
        compare(clamped, minValue, "clamped value not within range")
 
162
    }
 
163
 
87
164
    function test_lerp() {
88
165
        var lerped = MathUtils.lerp(0.25, 90, 0)
89
166
        compare(lerped, 67.5)