예제 #1
0
 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))
예제 #2
0
 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
예제 #3
0
 def test_unicode_1_128(self):
     """Accepts Unicode input"""
     test_case = u"abc"
     self.assertTrue(isinstance(CityHash128WithSeed(test_case), long))
예제 #4
0
 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")))
예제 #5
0
 def test_string_unicode_128(self):
     """Empty Python string has same hash value as empty Unicode string
     """
     self.assertEqual(CityHash128WithSeed(""), CityHash128WithSeed(u""))