コード例 #1
0
 def test_hashing_a_string_with_spaces_and_punctuation(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(
         mh.hash("it's a beautiful day in the \
                                    neighborhood"))
コード例 #2
0
 def test_that_i_can_hash_a_string_with_punctuation(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(mh.hash("it's"))
コード例 #3
0
 def test_that_i_can_hash_a_string_with_punctuation(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(mh.hash("it's"))
コード例 #4
0
 def test_getting_from_empty_list(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.get())
コード例 #5
0
 def test_getting_value_from_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertEqual(mh.get('hello'), 'world')
コード例 #6
0
 def test_storing_a_float(self):
     mh = NaiveHashTable()
     mh.set('a float', 1.0)
     self.assertIsNotNone(mh.get('a float'))
コード例 #7
0
 def test_to_see_if_hash_handles_float_keys_correctly(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.set(1.0, 'wun poin toe'))
コード例 #8
0
 def test_to_see_if_hash_handles_float_keys_correctly(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.set(1.0, 'wun poin toe'))
コード例 #9
0
 def test_getting_from_empty_list(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.get())
コード例 #10
0
 def test_storing_a_float(self):
     mh = NaiveHashTable()
     mh.set('a float', 1.0)
     self.assertIsNotNone(mh.get('a float'))
コード例 #11
0
 def test_to_see_if_hash_handles_nonstring_keys_correctly(self):  # passes
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.set(123, 'wun to tree'))
コード例 #12
0
 def test_storing_an_int(self):
     mh = NaiveHashTable()
     mh.set('an integer', 1)
     self.assertIsNotNone(mh.get('an integer'))
コード例 #13
0
 def test_storing_string_in_a_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertIsNotNone(mh.get('hello'))
コード例 #14
0
 def test_hashing_a_string_with_spaces_and_punctuation(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(mh.hash("it's a beautiful day in the \
                                    neighborhood"))
コード例 #15
0
 def test_storing_string_in_a_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertIsNotNone(mh.get('hello'))
コード例 #16
0
 def test_getting_nonexistant_key(self):
     mh = NaiveHashTable()
     mh.set('dog', 'food')
     self.assertRaises(TypeError, lambda:mh.get('cat'))
コード例 #17
0
 def test_storing_an_int(self):
     mh = NaiveHashTable()
     mh.set('an integer', 1)
     self.assertIsNotNone(mh.get('an integer'))
コード例 #18
0
 def test_to_see_if_i_hash_keys_correctly(self):  # passes
     mh = NaiveHashTable()
     self.assertEqual(mh.hash('hello'), 2)
コード例 #19
0
 def test_to_see_if_hash_handles_nonstring_keys_correctly(self):  # passes
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.set(123, 'wun to tree'))
コード例 #20
0
 def test_getting_value_from_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertEqual(mh.get('hello'), 'world')
コード例 #21
0
 def test_to_see_if_i_hash_keys_correctly(self):  # passes
     mh = NaiveHashTable()
     self.assertEqual(mh.hash('hello'), 2)
コード例 #22
0
 def test_getting_string_from_full_list(self):
     mh = NaiveHashTable()
     mh.set('i am not that', 1337)
     mh.set("who's hungry for", 3.14)
     mh.set('since feeling is first', 'who pays any attention to the')
     mh.set('syntax of things', 'will never wholly kiss you')
     mh.set('wholly to be a fool', 'while spring is in the world')
     mh.set('my blood approves', 'and kisses are a better fate')
     mh.set('than wisdom', 'lady i swear by all the flowers')
     mh.set('don\'t cry', 'the best gesture of my brain is less than')
     mh.set('your eyelid\'s flutter', 'which says')
     mh.set('we are for each other then', 'laugh, leaning back in my arms')
     mh.set('for life\'s not a paragraph', 'and death i think is no \
             parenthesis')
     mh.set('by', 'ee cummings')
     self.assertEqual(mh.get('than wisdom'), 'lady i swear by all the '
                         'flowers')
コード例 #23
0
 def test_getting_nonexistant_key(self):
     mh = NaiveHashTable()
     mh.set('dog', 'food')
     self.assertRaises(TypeError, lambda: mh.get('cat'))
コード例 #24
0
 def test_that_i_can_hash_a_string_with_spaces(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(mh.hash('hello dave'))
コード例 #25
0
 def test_getting_string_from_full_list(self):
     mh = NaiveHashTable()
     mh.set('i am not that', 1337)
     mh.set("who's hungry for", 3.14)
     mh.set('since feeling is first', 'who pays any attention to the')
     mh.set('syntax of things', 'will never wholly kiss you')
     mh.set('wholly to be a fool', 'while spring is in the world')
     mh.set('my blood approves', 'and kisses are a better fate')
     mh.set('than wisdom', 'lady i swear by all the flowers')
     mh.set('don\'t cry', 'the best gesture of my brain is less than')
     mh.set('your eyelid\'s flutter', 'which says')
     mh.set('we are for each other then', 'laugh, leaning back in my arms')
     mh.set('for life\'s not a paragraph', 'and death i think is no \
             parenthesis')
     mh.set('by', 'ee cummings')
     self.assertEqual(mh.get('than wisdom'), 'lady i swear by all the '
                      'flowers')
コード例 #26
0
 def test_that_i_can_hash_a_string_with_spaces(self):
     mh = NaiveHashTable()
     self.assertIsNotNone(mh.hash('hello dave'))