diff options
author | YilunAllenChen <allenchenyilun1999@gmail.com> | 2024-12-15 14:43:01 -0600 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-12-19 11:58:24 +0000 |
commit | a3018d0ab4e5d6ac0fa381d7798397554f1e5a91 (patch) | |
tree | a80016653c76d3b690a4fcc29d09ca7f004da152 /test | |
parent | c33b7341838d9286903c39697c82fc81f30fd437 (diff) | |
download | gleam_stdlib-a3018d0ab4e5d6ac0fa381d7798397554f1e5a91.tar.gz gleam_stdlib-a3018d0ab4e5d6ac0fa381d7798397554f1e5a91.zip |
add min/max to gleam/list
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/list_test.gleam | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index 79795e0..0e7e4de 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -1281,3 +1281,39 @@ pub fn shuffle_test() { list.range(0, recursion_test_cycles) |> list.shuffle() } + +pub fn max_test() { + [] + |> list.max(int.compare) + |> should.equal(Error(Nil)) + + [1, 3, 2] + |> list.max(int.compare) + |> should.equal(Ok(3)) + + [-1.0, 1.2, 1.104] + |> list.max(float.compare) + |> should.equal(Ok(1.2)) + + ["a", "c", "b"] + |> list.max(string.compare) + |> should.equal(Ok("c")) +} + +pub fn min_test() { + [] + |> list.min(int.compare) + |> should.equal(Error(Nil)) + + [1, 3, 2] + |> list.min(int.compare) + |> should.equal(Ok(1)) + + [-1.0, 1.2, 1.104] + |> list.min(float.compare) + |> should.equal(Ok(-1.0)) + + ["a", "c", "b"] + |> list.min(string.compare) + |> should.equal(Ok("a")) +} |