testsuite/hashindex.py: add comments about validity of hashtables

This commit is contained in:
Dan Christensen 2023-02-12 09:39:07 -05:00
parent c705c8573d
commit 3daf7e186d
1 changed files with 6 additions and 0 deletions

View File

@ -478,6 +478,9 @@ class HashIndexCompactTestCase(HashIndexDataTestCase):
self.write_entry(key, 0xFFFFFFFE, 0, 0)
def compare_indexes(self, idx1, idx2):
"""Check that the two hash tables contain the same data. idx1
is allowed to have "mis-filed" entries, because we only need to
iterate over it. But idx2 needs to support lookup."""
for k, v in idx1.iteritems():
assert v == idx2[k]
assert len(idx1) == len(idx2)
@ -504,6 +507,9 @@ class HashIndexCompactTestCase(HashIndexDataTestCase):
idx = self.index_from_data()
cpt = self.index_from_data()
cpt.compact()
# Note that idx is not a valid hash table, since the entries are not
# stored where they should be. So lookups of the form idx[k] can fail.
# But cpt is a valid hash table, since there are no empty buckets.
assert idx.size() == 1024 + num_buckets * (32 + 3 * 4)
assert cpt.size() == 1024 + num_entries * (32 + 3 * 4)
self.compare_indexes(idx, cpt)