summaryrefslogtreecommitdiff
path: root/src/expvar/expvar_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/expvar/expvar_test.go')
-rw-r--r--src/expvar/expvar_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/expvar/expvar_test.go b/src/expvar/expvar_test.go
index 7014063d4f..728e763896 100644
--- a/src/expvar/expvar_test.go
+++ b/src/expvar/expvar_test.go
@@ -161,6 +161,28 @@ func BenchmarkStringSet(b *testing.B) {
})
}
+func TestMapInit(t *testing.T) {
+ RemoveAll()
+ colors := NewMap("bike-shed-colors")
+ colors.Add("red", 1)
+ colors.Add("blue", 1)
+ colors.Add("chartreuse", 1)
+
+ n := 0
+ colors.Do(func(KeyValue) { n++ })
+ if n != 3 {
+ t.Errorf("after three Add calls with distinct keys, Do should invoke f 3 times; got %v", n)
+ }
+
+ colors.Init()
+
+ n = 0
+ colors.Do(func(KeyValue) { n++ })
+ if n != 0 {
+ t.Errorf("after Init, Do should invoke f 0 times; got %v", n)
+ }
+}
+
func TestMapCounter(t *testing.T) {
RemoveAll()
colors := NewMap("bike-shed-colors")