index: add basic hat test
This commit is contained in:
parent
55c21846b1
commit
b2ed42cec4
1 changed files with 15 additions and 0 deletions
|
@ -108,6 +108,21 @@ func TestIndexMapForeachWithID(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHashedArrayTree(t *testing.T) {
|
||||||
|
hat := newHAT()
|
||||||
|
const testSize = 1024
|
||||||
|
for i := uint(0); i < testSize; i++ {
|
||||||
|
rtest.Assert(t, hat.Size() == i, "expected hat size %v got %v", i, hat.Size())
|
||||||
|
e, idx := hat.Alloc()
|
||||||
|
rtest.Assert(t, idx == i, "expected entry at idx %v got %v", i, idx)
|
||||||
|
e.length = uint32(i)
|
||||||
|
}
|
||||||
|
for i := uint(0); i < testSize; i++ {
|
||||||
|
e := hat.Ref(i)
|
||||||
|
rtest.Assert(t, e.length == uint32(i), "expected entry to contain %v got %v", uint32(i), e.length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkIndexMapHash(b *testing.B) {
|
func BenchmarkIndexMapHash(b *testing.B) {
|
||||||
var m indexMap
|
var m indexMap
|
||||||
m.add(restic.ID{}, 0, 0, 0, 0) // Trigger lazy initialization.
|
m.add(restic.ID{}, 0, 0, 0, 0) // Trigger lazy initialization.
|
||||||
|
|
Loading…
Reference in a new issue