コード例 #1
0
 def test_getting_float_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('who\'s hungry for'), 3.14)
コード例 #2
0
 def test_getting_float_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('who\'s hungry for'), 3.14)
コード例 #3
0
 def test_getting_value_from_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertEqual(mh.get('hello'), 'world')
コード例 #4
0
 def test_getting_nonexistant_key(self):
     mh = NaiveHashTable()
     mh.set('dog', 'food')
     self.assertRaises(TypeError, lambda: mh.get('cat'))
コード例 #5
0
 def test_getting_from_empty_list(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.get())
コード例 #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_storing_an_int(self):
     mh = NaiveHashTable()
     mh.set('an integer', 1)
     self.assertIsNotNone(mh.get('an integer'))
コード例 #8
0
 def test_storing_string_in_a_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertIsNotNone(mh.get('hello'))
コード例 #9
0
 def test_getting_value_from_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertEqual(mh.get('hello'), 'world')
コード例 #10
0
 def test_getting_nonexistant_key(self):
     mh = NaiveHashTable()
     mh.set('dog', 'food')
     self.assertRaises(TypeError, lambda:mh.get('cat'))
コード例 #11
0
 def test_getting_from_empty_list(self):
     mh = NaiveHashTable()
     self.assertRaises(TypeError, lambda: mh.get())
コード例 #12
0
 def test_storing_a_float(self):
     mh = NaiveHashTable()
     mh.set('a float', 1.0)
     self.assertIsNotNone(mh.get('a float'))
コード例 #13
0
 def test_storing_an_int(self):
     mh = NaiveHashTable()
     mh.set('an integer', 1)
     self.assertIsNotNone(mh.get('an integer'))
コード例 #14
0
 def test_storing_string_in_a_bucket(self):
     mh = NaiveHashTable()
     mh.set('hello', 'world')
     self.assertIsNotNone(mh.get('hello'))