mDNS/DNS-SD service discovery for OCaml (RFC 6762/6763)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Tidy: use Option/Result combinators across packages

- Replace match with Option.value, Option.iter, Result.value
- Simplify ignore patterns
- 6 files, 12 pattern improvements

+5 -7
+4 -4
fuzz/fuzz_mdns.ml
··· 7 7 8 8 (* Test that parse never crashes on arbitrary input *) 9 9 let test_parse_crash_safety buf = 10 - (match Mdns.parse buf with Some _ -> () | None -> ()); 10 + ignore (Mdns.parse buf); 11 11 check true 12 12 13 13 (* Test that merge is associative *) 14 14 let test_merge_associative buf1 buf2 buf3 = 15 - let r1 = match Mdns.parse buf1 with Some r -> r | None -> Mdns.empty in 16 - let r2 = match Mdns.parse buf2 with Some r -> r | None -> Mdns.empty in 17 - let r3 = match Mdns.parse buf3 with Some r -> r | None -> Mdns.empty in 15 + let r1 = Mdns.parse buf1 |> Option.value ~default:Mdns.empty in 16 + let r2 = Mdns.parse buf2 |> Option.value ~default:Mdns.empty in 17 + let r3 = Mdns.parse buf3 |> Option.value ~default:Mdns.empty in 18 18 let left = Mdns.merge [ Mdns.merge [ r1; r2 ]; r3 ] in 19 19 let right = Mdns.merge [ r1; Mdns.merge [ r2; r3 ] ] in 20 20 (* Check same number of records (order may differ) *)
+1 -3
test/test_mdns.ml
··· 38 38 | Some r -> 39 39 Alcotest.(check int) "PTR count" 1 (List.length r.ptrs); 40 40 let _, instance = List.hd r.ptrs in 41 - let name = 42 - match Domain_name.get_label instance 0 with Ok n -> n | Error _ -> "" 43 - in 41 + let name = Domain_name.get_label instance 0 |> Result.value ~default:"" in 44 42 Alcotest.(check string) "Instance name" "My Device" name 45 43 46 44 let test_srv () =