File: fuzz.ml

package info (click to toggle)
ocaml-uri 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,012 kB
  • sloc: ml: 3,014; makefile: 16
file content (46 lines) | stat: -rw-r--r-- 1,949 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
open Crowbar

let () =
  add_test ~name:"create" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> to_string) with _ -> "" in
    let y = try Uri_legacy.(of_string a |> to_string) with _ -> "" in
    check_eq ~pp:pp_string x y
  );
  add_test ~name:"query" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> query) with _ -> [] in
    let y = try Uri_legacy.(of_string a |> query) with _ -> [] in
    check_eq x y
  );
  add_test ~name:"scheme" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> scheme) with _ -> None in
    let y = try Uri_legacy.(of_string a |> scheme) with _ -> None in
    check_eq x y
  );
  add_test ~name:"host" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> host) with _ -> None in
    let y = try Uri_legacy.(of_string a |> host) with _ -> None in
    check_eq x y
  );
  add_test ~name:"userinfo" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> userinfo) with _ -> None in
    let y = try Uri_legacy.(of_string a |> userinfo) with _ -> None in
    check_eq x y
  );
  add_test ~name:"port" [bytes] (fun a ->
    (* Parse \n as this is a known deviation of behaviour *)
    let a = Str.(global_replace (regexp_string "\n") a "") in
    let x = try Uri.(of_string a |> port) with _ -> None in
    let y = try Uri_legacy.(of_string a |> port) with _ -> None in
    check_eq x y
  );