Skip to content

Commit

Permalink
test: add more repn tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrinberg committed Sep 10, 2024
1 parent 958139e commit fa3b364
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib_test/expect/test_re.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,28 @@ let%expect_test "rep1" =
;;

let%expect_test "repn" =
test_re (repn (char 'a') 0 None) "";
let a = char 'a' in
test_re (repn a 0 None) "";
[%expect {| [| (0, 0) |] |}];
test_re (repn (char 'a') 0 (Some 0)) "";
test_re (repn a 2 None) "a";
[%expect {| Not_found |}];
test_re (repn a 2 None) "aa";
[%expect {| [| (0, 2) |] |}];
test_re (repn a 0 (Some 0)) "";
[%expect {| [| (0, 0) |] |}];
test_re (repn (char 'a') 1 (Some 2)) "a";
test_re (repn a 1 (Some 2)) "a";
[%expect {| [| (0, 1) |] |}];
test_re (repn (char 'a') 1 (Some 2)) "aa";
test_re (repn a 1 (Some 2)) "aa";
[%expect {| [| (0, 2) |] |}];
test_re (repn (char 'a') 1 (Some 2)) "";
test_re (repn a 1 (Some 2)) "";
[%expect {| Not_found |}];
test_re (repn (char 'a') 1 (Some 2)) "aaa";
test_re (repn a 1 (Some 2)) "aaa";
[%expect {| [| (0, 2) |] |}];
invalid_argument (fun () -> repn empty (-1) None);
[%expect {| Invalid_argument "Re.repn" |}];
invalid_argument (fun () -> repn empty 1 (Some 0));
[%expect {| Invalid_argument "Re.repn" |}];
invalid_argument (fun () -> repn empty 4 (Some 3));
[%expect {| Invalid_argument "Re.repn" |}]
;;

Expand Down

0 comments on commit fa3b364

Please sign in to comment.