aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/pair_test.gleam34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/gleam/pair_test.gleam b/test/gleam/pair_test.gleam
index 54a12af..5dd2690 100644
--- a/test/gleam/pair_test.gleam
+++ b/test/gleam/pair_test.gleam
@@ -26,3 +26,37 @@ pub fn swap_test() {
|> pair.swap
|> expect.equal(_, pair.Pair("2", 1))
}
+
+pub fn map_first_test() {
+ let inc = fn(a) {
+ a + 1
+ }
+ pair.map_first(pair.Pair(1, 2), inc)
+ |> expect.equal(_, pair.Pair(2, 2))
+
+ pair.map_first(pair.Pair(8,2), inc)
+ |> expect.equal(_, pair.Pair(9, 2))
+
+ pair.map_first(pair.Pair(0,-2), inc)
+ |> expect.equal(_, pair.Pair(1, -2))
+
+ pair.map_first(pair.Pair(-10, 20), inc)
+ |> expect.equal(_, pair.Pair(-9, 20))
+}
+
+pub fn map_second_test() {
+ let dec = fn(a) {
+ a - 1
+ }
+ pair.map_second(pair.Pair(1, 2), dec)
+ |> expect.equal(_, pair.Pair(1, 1))
+
+ pair.map_second(pair.Pair(8,2), dec)
+ |> expect.equal(_, pair.Pair(8, 1))
+
+ pair.map_second(pair.Pair(0,-2), dec)
+ |> expect.equal(_, pair.Pair(0, -3))
+
+ pair.map_second(pair.Pair(-10, 20), dec)
+ |> expect.equal(_, pair.Pair(-10, 19))
+}