aboutsummaryrefslogtreecommitdiff
path: root/test/gleam/int_test.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'test/gleam/int_test.gleam')
-rw-r--r--test/gleam/int_test.gleam15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index 11906db..bec9624 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -12,6 +12,21 @@ pub fn absolute_value_test() {
|> should.equal(123)
}
+pub fn clamp_test() {
+ int.clamp(40, min: 30, max: 50)
+ |> should.equal(40)
+
+ int.clamp(20, min: 30, max: 50)
+ |> should.equal(30)
+
+ int.clamp(60, min: 30, max: 50)
+ |> should.equal(50)
+
+ // If the bounds are reversed we return the min
+ int.clamp(100, min: 50, max: 30)
+ |> should.equal(50)
+}
+
pub fn to_string_test() {
123
|> int.to_string