Skip to content

Commit

Permalink
Add TestHandleMapGeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
akalin committed Apr 22, 2015
1 parent 9592df4 commit ffed29e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions fuse/nodefs/handle_test.go
Expand Up @@ -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)
}
}

0 comments on commit ffed29e

Please sign in to comment.