aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/int_test.gleam27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index 71c526b..26e36ba 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -273,7 +273,7 @@ pub fn power_test() {
// int.power(-1, 0.5) is equivalent to int.square_root(-1) and should
// return an error as an imaginary number would otherwise have to be
- // returned
+ // returned
int.power(-1, 0.5)
|> should.equal(Error(Nil))
@@ -286,7 +286,7 @@ pub fn power_test() {
int.power(0, -1.0)
|> should.equal(Error(Nil))
- // Check that a negative base and exponent is fine as long as the
+ // Check that a negative base and exponent is fine as long as the
// exponent is not fractional
int.power(-2, -1.0)
|> should.equal(Ok(-0.5))
@@ -423,3 +423,26 @@ pub fn divide_test() {
int.divide(1, by: 0)
|> should.equal(Error(Nil))
}
+
+pub fn floor_divide_test() {
+ int.floor_divide(1, 1)
+ |> should.equal(Ok(1))
+
+ int.floor_divide(1, 0)
+ |> should.equal(Error(Nil))
+
+ int.floor_divide(0, by: 1)
+ |> should.equal(Ok(0))
+
+ int.floor_divide(1, by: 0)
+ |> should.equal(Error(Nil))
+
+ int.floor_divide(5, by: 2)
+ |> should.equal(Ok(2))
+
+ int.floor_divide(6, by: -4)
+ |> should.equal(Ok(-2))
+
+ int.floor_divide(-99, by: 2)
+ |> should.equal(Ok(-50))
+}