def test_unicode_2_128_seed(self): """Accepts Unicode input outside of ASCII range""" test_case = u'\u2661' self.assertTrue( isinstance( CityHash128WithSeed(test_case, seed=CityHash128WithSeed(test_case)), long))
def _hash_fun_128(item, seed=0): type_of_x = type(item) if type_of_x == str: value = item elif type_of_x == unicode: value = item.encode("utf-8") else: value = repr(item) part_a, part_b = CityHash128WithSeed(value, (seed, seed)) return (1 << 64) * part_a + part_b
def test_unicode_1_128(self): """Accepts Unicode input""" test_case = u"abc" self.assertTrue(isinstance(CityHash128WithSeed(test_case), long))
def test_consistent_encoding_128(self): """ASCII-range Unicode strings have the same hash values as ASCII strings """ text = u"abracadabra" self.assertEqual(CityHash128WithSeed(text), CityHash128WithSeed(text.encode("utf-8")))
def test_string_unicode_128(self): """Empty Python string has same hash value as empty Unicode string """ self.assertEqual(CityHash128WithSeed(""), CityHash128WithSeed(u""))