mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
test: add a test for update
This commit is contained in:
parent
e6f77edf1a
commit
5ee25afad5
1 changed files with 13 additions and 0 deletions
|
|
@ -103,6 +103,10 @@ module type S = sig
|
|||
?pp_sep:unit printer -> key printer -> 'a printer -> 'a t printer
|
||||
end
|
||||
|
||||
(*$inject
|
||||
module M = CCMap.Make(String)
|
||||
*)
|
||||
|
||||
module Make(O : Map.OrderedType) = struct
|
||||
module M = Map.Make(O)
|
||||
|
||||
|
|
@ -175,6 +179,15 @@ module Make(O : Map.OrderedType) = struct
|
|||
| None -> M.remove k m
|
||||
| Some v' -> M.add k v' m
|
||||
|
||||
(*$= & ~printer:CCFormat.(to_string @@ Dump.(list (pair string int)))
|
||||
["a", 1; "b", 20] \
|
||||
(M.of_list ["b", 2; "c", 3] \
|
||||
|> M.update "a" (function _ -> Some 1) \
|
||||
|> M.update "c" (fun _ -> None) \
|
||||
|> M.update "b" (CCOpt.map (fun x -> x * 10)) \
|
||||
|> M.to_list |> List.sort CCOrd.compare)
|
||||
*)
|
||||
|
||||
include M
|
||||
|
||||
let get = find_opt
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue