2
* Copyright 2014 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import Ubuntu.Components 1.1
24
function test_clamp_positive_lower() {
29
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
30
compare(clamped, minValue, "clamped value not within range")
33
function test_clamp_positive_greater() {
38
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
39
compare(clamped, maxValue, "clamped value not within range")
42
function test_clamp_positive_within() {
47
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
48
compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
51
function test_clamp_positive_on_border() {
56
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
57
compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
60
function test_clamp_negative_lower() {
65
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
66
compare(clamped, minValue, "clamped value not within range")
69
function test_clamp_negative_greater() {
74
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
75
compare(clamped, maxValue, "clamped value not within range")
78
function test_clamp_postive_and_negative_greater() {
83
var clamped = MathUtils.clamp(clampValue, minValue, maxValue)
84
compare(clamped, maxValue, "clamped value not within range")
87
function test_lerp() {
88
var lerped = MathUtils.lerp(0.25, 90, 0)
92
function test_project_value() {
93
var projectedValue = MathUtils.projectValue(5, 1, 100, 2, 200)
94
compare(projectedValue, 10)
97
function test_clamp_and_project() {
98
var clampedAndProjectedValue = MathUtils.clampAndProject(5, 1, 10, 2, 200)
99
compare(clampedAndProjectedValue, 90)