cheesebot/ocaml/test.ml

45 lines
987 B
OCaml
Raw Normal View History

2014-03-03 23:33:47 +01:00
open OUnit2
let test_get_title test_ctxt =
let body = "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Fabien</title>
</head>
<body>
<h1>Header</h1>
</body>
</html>" in
let title = SimpleHttp.get_http_title body in
assert_equal (Some "Fabien") title
let test_remove_spaces test_ctxt =
let str = "
foo bar baz
" in
2014-12-21 17:00:07 +01:00
let cleaned_str = Evaluate.remove_spaces (Some str) in
assert_equal (Some "foo bar baz") cleaned_str
2014-03-03 23:33:47 +01:00
let test_escape_characters text_ctx =
let html_str = "I&#039;ll" in
let expected = "I'll" in
assert_equal expected (SimpleHttp.decode_esc_char html_str)
2014-03-03 23:33:47 +01:00
(* Name the test cases and group them together *)
let suite =
"suite">:::
["test get_title">:: test_get_title;
"test remove_spaces">:: test_remove_spaces;
"test HTML character escaping">:: test_escape_characters]
2014-03-03 23:33:47 +01:00
let () =
run_test_tt_main suite