+let test_uri uri = try test_uri uri; true with _ -> false
+
+let _ =
+ let idx = ref 0 in
+ let ok = ref [] in
+ let nok = ref [] in
+ try
+ let mode = if Sys.argv.(1) = "-" then `Stdin else `Cmdline in
+ while true do
+ incr idx;
+ let uri_str =
+ match mode with
+ | `Stdin -> input_line stdin
+ | `Cmdline -> Sys.argv.(!idx)
+ in
+ printf "Testing URI: %s ...\t";
+ let uri = UriManager.uri_of_string uri_str in
+ if test_uri uri then begin
+ print_endline "\e[01;32m[ OK ]\e[00m";
+ ok := uri_str :: !ok
+ end else begin
+ print_endline "\e[01;31m[ FAILED ]\e[00m";
+ nok := uri_str :: !nok
+ end
+ done
+ with Invalid_argument _ | End_of_file ->
+ print_newline ();
+ print_endline "TestLibrary report";
+ print_endline "Succeeded URIs:";
+ List.iter (fun s -> print_endline ("\t" ^ s)) (List.rev !ok);
+ print_endline "Failed URIs:";
+ List.iter (fun s -> print_endline ("\t" ^ s)) (List.rev !nok);
+ print_newline ()