12345678910111213141516171819202122232425262728293031323334353637383940(*
Unit tests for SPcre
*)lettest_match_limit_ok()=letrex=SPcre.regexp"(a+)+$"inmatchSPcre.pmatch~rex"aaaaaaaaaaaaaaaaa!"with|Ok_->()|ErrorPcre.MatchLimit->Alcotest.fail"should not have failed with error MatchLimit"|Error_->Alcotest.fail"unexpected error"lettest_match_limit_fail()=letrex=SPcre.regexp"(a+)+$"inmatchSPcre.pmatch~rex"aaaaaaaaaaaaaaaaaa!"with|Ok_->Alcotest.fail"should have failed with error MatchLimit"|ErrorPcre.MatchLimit->()|Error_->Alcotest.fail"unexpected error"lettest_register_exception_printer()=(* This is a little dirty since we can't undo it. *)SPcre.register_exception_printer();letmsg=tryignore(SPcre.regexp"???");Alcotest.fail"should have failed to compile the regexp"with|e->Printexc.to_stringeinAlcotest.(checkstring)"equal""Pcre.Error(Pcre.BadPattern(\"nothing to repeat\", pos=0))"msglettests=Testutil.pack_tests"pcre settings"[("match limit ok",test_match_limit_ok);("match limit fail",test_match_limit_fail);("exception printer",test_register_exception_printer);]