From fcf9fa63b211b92918afbe6cf859b7eca58d69fa Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Fri, 31 Jul 2015 21:31:22 +0200 Subject: [PATCH] Add unit test for url parser. --- ocaml/test.ml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ocaml/test.ml b/ocaml/test.ml index 8bd6caa..5226619 100644 --- a/ocaml/test.ml +++ b/ocaml/test.ml @@ -38,6 +38,21 @@ let test_https test_ctx = let title = SimpleHttp.get_http_title (SimpleHttp.get_body url) in assert_equal (Some "Wikipedia, the free encyclopedia") title + +let test_is_url test_ctx = + let urls = [ + ("http://foo.bar", true); + ("https://foo.bar", true); + ("www.foo.bar", true); + ("foo.bar", true); + ("http://www.foo.bar", true); + ("foo-bar", false); + ("http://www.foo.bar/baz/quuz", true) + ] in + let check (url, b) = assert_equal (Evaluate.is_url url) b in + List.iter check urls + + (* Name the test cases and group them together *) let suite = "suite">:::