aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian <s@porto5.com>2022-02-18 14:51:41 +1100
committerLouis Pilfold <louis@lpil.uk>2022-02-22 13:19:08 +0000
commit34ce79f8e896e23348d88b5bfe0c3b7a28d273d8 (patch)
treecbbc5694d913712da461eee38b3b864900832a4f /test
parent813f11c00795db6036362e9392300aec13823d34 (diff)
downloadgleam_stdlib-34ce79f8e896e23348d88b5bfe0c3b7a28d273d8.tar.gz
gleam_stdlib-34ce79f8e896e23348d88b5bfe0c3b7a28d273d8.zip
Add float.compare_with_tolerance
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index c7107d9..287dc4b 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -77,6 +77,26 @@ pub fn compare_test() {
|> should.equal(order.Gt)
}
+pub fn loosely_compare_test() {
+ float.loosely_compare(10.2, 10.5, tolerating: 0.)
+ |> should.equal(order.Lt)
+
+ float.loosely_compare(10.2, with: 10.5, tolerating: 0.31)
+ |> should.equal(order.Eq)
+
+ float.loosely_compare(10.5, 10.2, 0.31)
+ |> should.equal(order.Eq)
+
+ float.loosely_compare(10.2, 10.5, 0.29)
+ |> should.equal(order.Lt)
+
+ float.loosely_compare(10.5, 10.2, 0.29)
+ |> should.equal(order.Gt)
+
+ float.loosely_compare(-10.2, -10.5, 0.31)
+ |> should.equal(order.Eq)
+}
+
pub fn ceiling_test() {
8.1
|> float.ceiling