Commit ffed29ec authored by Frederick Akalin's avatar Frederick Akalin

Add TestHandleMapGeneration

parent 9592df4a
......@@ -104,3 +104,24 @@ func TestHandleMapMultiple(t *testing.T) {
}
}
}
func TestHandleMapGeneration(t *testing.T) {
hm := newPortableHandleMap()
h1, g1 := hm.Register(&handled{})
forgotten, _ := hm.Forget(h1, 1)
if !forgotten {
t.Fatalf("unref did not forget object.")
}
h2, g2 := hm.Register(&handled{})
if h1 != h2 {
t.Fatalf("register should reuse handle: got %d want %d.", h2, h1)
}
if g1 >= g2 {
t.Fatalf("register should increase generation: got %d want greater than %d.", g2, g1)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment