diff --git a/lib/irc/mode.ml b/lib/irc/mode.ml index 8c5f966..52b0dc1 100644 --- a/lib/irc/mode.ml +++ b/lib/irc/mode.ml @@ -249,7 +249,7 @@ let%expect_test _ = let print_set_nl s = Printf.printf "[%s]\n" (Set.to_string s) in let print_bool_nl b = print_endline (if b then "true" else "false") in - let print_change_nl c = Format.printf "%a\n" Set.pp_change c in + let print_change_nl c = Format.kasprintf print_string "%a\n" Set.pp_change c in print_set_nl Set.empty; [%expect {| [] |}]; print_set_nl Set.(of_string "i"); [%expect {| [i] |}]; @@ -279,3 +279,27 @@ let%expect_test _ = let m, c = Set.normalize (Set.of_string "iw") (Parse.user_modes "-w+io") in Format.printf "%a -> [%a]" Set.pp_change c Set.pp m; [%expect {| +o-w -> [io] |}]; + + let print_chan_modes (m : Parse.chan_modes) = + Format.printf "[%a" Set.pp_change m.chan_modes; + begin match m.chan_limit with + | Some (`set n) -> Format.printf " +l:%d" n + | Some `unset -> Format.printf " -l" + | None -> () + end; + begin match m.chan_key with + | Some (`set k) -> Format.printf " +k:%S" k + | Some `unset -> Format.printf " -k" + | None -> () + end; + Format.printf "]\n@." + in + + print_chan_modes (Parse.chan_modes "+im-nm+s" []); + [%expect {| [+is-mn] |}]; + + print_chan_modes (Parse.chan_modes "+l-ik+lt" ["100"; "*"; "200"]); + [%expect {| [+t-i +l:200 -k] |}]; + + print_chan_modes (Parse.chan_modes "+k-k+k" ["a"; "b"; "c"]); + [%expect {| [+ +k:"c"] |}];