Test linked list in both directions in base tile hash.

This commit is contained in:
Sascha L. Teichmann 2016-05-11 18:43:20 +02:00
parent 9a355d08fd
commit 674912ed5f

View File

@ -26,7 +26,27 @@ func randomBaseTileHash(updates int) *BaseTileHash {
return bth return bth
} }
func TestBaseTileHash(t *testing.T) { func TestBaseTileHashLenList(t *testing.T) {
for _, updates := range []int{53, 111, 1345, 11261} {
bth := randomBaseTileHash(updates)
countNext := 0
for cur := bth.root.next; cur != &bth.root; cur = cur.next {
countNext++
}
countPrev := 0
for cur := bth.root.prev; cur != &bth.root; cur = cur.prev {
countPrev++
}
if countPrev != countNext {
t.Errorf("count prev != count next: %d %d", countPrev, countNext)
}
if countPrev != len(bth.hashes) {
t.Errorf("count prev != len(hash): %d %d", countPrev, len(bth.hashes))
}
}
}
func TestBaseTileHashIntegrity(t *testing.T) {
for _, updates := range []int{10, 100, 1000, 10000} { for _, updates := range []int{10, 100, 1000, 10000} {
bth := randomBaseTileHash(updates) bth := randomBaseTileHash(updates)
entries := map[*btHashEntry]bool{} entries := map[*btHashEntry]bool{}