From 42ea437f216085e08de7a7ebd9f610bf8fed2c43 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Sat, 10 Jan 2015 10:41:09 -0800 Subject: [PATCH] Test RemoveRandom() --- hashmap/hashmap_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hashmap/hashmap_test.go b/hashmap/hashmap_test.go index 685df1ba..dfadc30a 100644 --- a/hashmap/hashmap_test.go +++ b/hashmap/hashmap_test.go @@ -240,6 +240,25 @@ func TestFalseLookup(t *testing.T) { } } +func TestRemoveRandom(t *testing.T) { + h := New() + h.RemoveRandom() + + h.Set(foo, "1") + h.Set(bar, "1") + h.Set(baz, "1") + + if h.Count() != 3 { + t.Fatalf("Expected 3 members, got %d\n", h.Count()) + } + + h.RemoveRandom() + + if h.Count() != 2 { + t.Fatalf("Expected 2 members, got %d\n", h.Count()) + } +} + func Benchmark_GoMap___GetSmallKey(b *testing.B) { b.StopTimer() b.SetBytes(1)