コード例 #1
0
 def test_clear(self):
     """
     A cleared HashTable has an empty data array.
     """
     h = HashTable(3)
     h['foo'] = 'bar'
     h.clear()
     self.assertEqual([[], [], []], h.data)
コード例 #2
0
ファイル: tests.py プロジェクト: jeremy2918/data-structures
 def test_clear(self):
     table = HashTable()
     table.insert('key1', 1)
     table.insert('key2', 2)
     table.insert('key3', 3)
     self.assertEqual(len(table), 3)
     table.clear()
     self.assertEqual(len(table), 0)
     self.assertEqual(table.table, [None] * table.capacity)