コード例 #1
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_bucket_for_gives_correct_bucket(self):
     self.em.add(self.ce)
     d1 = hash.distance(self.s.ipp, self.ce)
     assert self.em._buckets[d1] is self.em.bucket_for(self.ce)
     self.em.add(self.fe)
     d2 = hash.distance(self.s.ipp, self.fe)
     assert self.em._buckets[d2] == self.em.bucket_for(self.fe)
コード例 #2
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_supports_hash_ipptuple_or_end(self):
     a = hash.distance(selfipp, faripp)
     b = hash.distance(hash.hexhash(selfipp), hash.hexhash(faripp))
     c = hash.distance(hash.hexhash(selfipp), faripp)
     d = hash.distance(selfipp, hash.hexhash(faripp))
     e = hash.distance(selfipp, End(faripp))
     f = hash.distance(End(selfipp), faripp)
     g = hash.distance(End(selfipp), End(faripp))
     assert a == b == c == d == e == f == g
コード例 #3
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_is_an_int(self):
     assert isinstance(hash.distance(selfipp, closeipp), int)
コード例 #4
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_correct_for_closeipp(self):
     assert hash.distance(selfipp, closeipp) == 1
コード例 #5
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_correct_for_faripp(self):
     assert hash.distance(selfipp, faripp) == 17
コード例 #6
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_is_commutative(self):
     assert hash.distance(selfipp, faripp) == hash.distance(faripp, selfipp)
コード例 #7
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_distance_to_self_is_zero(self):
     assert hash.distance(selfipp, selfipp) == 0
コード例 #8
0
ファイル: test_pylehash.py プロジェクト: warner/pylehash
 def test_end_manager_add_end_adds_end_at_correct_distance(self):
     self.em.add(self.ce)
     bucket = self.em._buckets[hash.distance(self.s.ipp, self.ce)]
     assert bucket[hash.hexhash(self.ce)]