···7788(* Test that parse never crashes on arbitrary input *)
99let test_parse_crash_safety buf =
1010- (match Mdns.parse buf with Some _ -> () | None -> ());
1010+ ignore (Mdns.parse buf);
1111 check true
12121313(* Test that merge is associative *)
1414let test_merge_associative buf1 buf2 buf3 =
1515- let r1 = match Mdns.parse buf1 with Some r -> r | None -> Mdns.empty in
1616- let r2 = match Mdns.parse buf2 with Some r -> r | None -> Mdns.empty in
1717- let r3 = match Mdns.parse buf3 with Some r -> r | None -> Mdns.empty in
1515+ let r1 = Mdns.parse buf1 |> Option.value ~default:Mdns.empty in
1616+ let r2 = Mdns.parse buf2 |> Option.value ~default:Mdns.empty in
1717+ let r3 = Mdns.parse buf3 |> Option.value ~default:Mdns.empty in
1818 let left = Mdns.merge [ Mdns.merge [ r1; r2 ]; r3 ] in
1919 let right = Mdns.merge [ r1; Mdns.merge [ r2; r3 ] ] in
2020 (* Check same number of records (order may differ) *)
+1-3
test/test_mdns.ml
···3838 | Some r ->
3939 Alcotest.(check int) "PTR count" 1 (List.length r.ptrs);
4040 let _, instance = List.hd r.ptrs in
4141- let name =
4242- match Domain_name.get_label instance 0 with Ok n -> n | Error _ -> ""
4343- in
4141+ let name = Domain_name.get_label instance 0 |> Result.value ~default:"" in
4442 Alcotest.(check string) "Instance name" "My Device" name
45434644let test_srv () =