2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU 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 General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import "../../../Components/Math.js" as MathLocal
26
property int clampValue
29
function test_clamp_positive_lower() {
34
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
35
compare(clamped, minValue, "clamped value not within range")
38
function test_clamp_positive_greater() {
43
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
44
compare(clamped, maxValue, "clamped value not within range")
47
function test_clamp_positive_within() {
52
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
53
compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
56
function test_clamp_positive_on_border() {
61
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
62
compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
65
function test_clamp_negative_lower() {
70
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
71
compare(clamped, minValue, "clamped value not within range")
74
function test_clamp_negative_greater() {
79
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
80
compare(clamped, maxValue, "clamped value not within range")
83
function test_clamp_postive_and_negative_greater() {
88
clamped = MathLocal.clamp(clampValue, minValue, maxValue)
89
compare(clamped, maxValue, "clamped value not within range")