From 485c6a11b549cfbcf29b73902ce11a9feceddae5 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 21 Feb 2016 17:19:19 +0100 Subject: [PATCH] test --- src/core/CCHashtbl.ml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/CCHashtbl.ml b/src/core/CCHashtbl.ml index daf462e0..66971f1b 100644 --- a/src/core/CCHashtbl.ml +++ b/src/core/CCHashtbl.ml @@ -222,6 +222,20 @@ module Make(X : Hashtbl.HashedType) then remove tbl x else replace tbl x (n+by) + (*$R + let tbl = T.create 32 in + T.incr tbl 1 ; + T.incr tbl 2; + T.incr tbl 1; + assert_equal 2 (T.find tbl 1); + assert_equal 1 (T.find tbl 2); + assert_equal 2 (T.length tbl); + T.decr tbl 2; + assert_equal 0 (T.get_or tbl 2 ~or_:0); + assert_equal 1 (T.length tbl); + assert_bool "2 removed" (not (T.mem tbl 2)); + *) + let decr ?(by=1) tbl x = try let n = find tbl x in