2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-30 13:40:36 +00:00

index: add basic hat test

This commit is contained in:
Michael Eischer 2023-06-16 23:12:30 +02:00
parent 55c21846b1
commit b2ed42cec4

View File

@ -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) {
var m indexMap
m.add(restic.ID{}, 0, 0, 0, 0) // Trigger lazy initialization.