aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 4c49f69..6a737e7 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -213,6 +213,32 @@ pub fn truncate_test() {
|> should.equal(-7)
}
+pub fn to_precision_test() {
+ float.to_precision(2.43434348473, 2)
+ |> should.equal(2.43)
+
+ float.to_precision(2.43534348473, 2)
+ |> should.equal(2.44)
+
+ float.to_precision(-2.43534348473, 2)
+ |> should.equal(-2.44)
+
+ float.to_precision(547_890.453444, -3)
+ |> should.equal(548_000.0)
+
+ float.to_precision(547_490.453444, -3)
+ |> should.equal(547_000.0)
+
+ float.to_precision(-547_490.453444, -3)
+ |> should.equal(-547_000.0)
+
+ float.to_precision(435.3224, 0)
+ |> should.equal(435.0)
+
+ float.to_precision(435.3224, -0)
+ |> should.equal(435.0)
+}
+
pub fn min_test() {
float.min(0.0, 0.0)
|> should.equal(0.0)