Skip to content

Commit

Permalink
Adding tests for Int and Int64
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain Frisch committed May 11, 2021
1 parent 1119bd6 commit fadd9a0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions testsuite/tests/basic/boxedints.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module type TESTSIG = sig
val div: t -> t -> t
val unsigned_div: t -> t -> t
val rem: t -> t -> t
val min: t -> t -> t
val max: t -> t -> t
val logand: t -> t -> t
val logor: t -> t -> t
val logxor: t -> t -> t
Expand Down Expand Up @@ -227,6 +229,10 @@ struct
11, 1234567, -12345678];
test 12 (rem min_int (of_int (-1))) (of_int 0);

testing_function "min/max";
test 1 (max (of_int 2) (of_int 3)) (of_int 3);
test 2 (min (of_int 2) (of_int 3)) (of_int 2);

testing_function "and";
List.iter
(fun (n, a, b, c) -> test n (logand (of_string a) (of_string b))
Expand Down Expand Up @@ -487,6 +493,10 @@ struct
11, 1234567, -12345678];
test 12 (rem min_int (of_int (-1))) (of_int 0);

testing_function "min/max";
test 1 (max (of_int 2) (of_int 3)) (of_int 3);
test 2 (min (of_int 2) (of_int 3)) (of_int 2);

testing_function "and";
List.iter
(fun (n, a, b, c) -> test n (logand (of_string a) (of_string b))
Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/basic/boxedints.reference
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ unsigned_div
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11...
mod
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12...
min/max
1... 2...
and
1... 2... 3... 4... 5...
or
Expand Down Expand Up @@ -66,6 +68,8 @@ unsigned_div
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11...
mod
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12...
min/max
1... 2...
and
1... 2... 3... 4... 5...
or
Expand Down Expand Up @@ -105,6 +109,8 @@ unsigned_div
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11...
mod
1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12...
min/max
1... 2...
and
1... 2... 3... 4... 5...
or
Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/lib-int/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ let test_string_conv () =
assert (Int.of_string "" = None); *)
()

let test_min_max () =
assert (Int.max 2 3 = 3);
assert (Int.min 2 3 = 2)


let tests () =
test_consts ();
test_arith ();
Expand All @@ -65,6 +70,7 @@ let tests () =
test_compare ();
test_float_conv ();
test_string_conv ();
test_min_max ();
()

let () =
Expand Down
5 changes: 5 additions & 0 deletions testsuite/tests/lib-int64/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ let test_string_conv () =
assert (Int64.of_string "" = None); *)
()

let test_min_max () =
assert (Int64.max 2L 3L = 3L);
assert (Int64.min 2L 3L = 2L)

let tests () =
test_consts ();
test_arith ();
Expand All @@ -64,6 +68,7 @@ let tests () =
test_compare ();
test_float_conv ();
test_string_conv ();
test_min_max ();
()

let () =
Expand Down

0 comments on commit fadd9a0

Please sign in to comment.