def test_sepchain4(self):
     ht = HashTableSepchain()
     num_items = int(47 * 1.5) - 1
     for i in range(num_items):
         ht.put(chr(i), i)
     self.assertEqual(ht.size(), num_items)
     self.assertTrue(1.0 < ht.load_factor() <= 1.5)
Beispiel #2
0
    def test_sepchain3(self):
        ht = HashTableSepchain()
        for i in range(34):
            ht.put(chr(i), i)

        self.assertEqual(ht.size(), 34)
        self.assertTrue(1.0 < ht.load_factor() <= 1.5)
 def test_sepchain1(self):
     ht = HashTableSepchain()
     for i in range(11):
         ht.put(str(i), i)
     self.assertEqual(ht.size(), 11)
     self.assertEqual(ht.load_factor(), 1.0)
     self.assertTrue(ht.contains('0'))
     self.assertTrue(ht.contains('1'))
     print(ht.hash_table)
     self.assertTrue(ht.contains('10'))
     self.assertFalse(ht.contains('11'))
 def test_sepchain2(self):
     ht = HashTableSepchain()
     for i in range(20):
         print(ht.table_size)
         ht.put(chr(i), i)
     self.assertEqual(ht.size(), 20)
     self.assertTrue(ht.load_factor() <= 1.0)
     self.assertTrue(ht.contains(chr(0)))
     self.assertTrue(ht.contains(chr(1)))
     self.assertTrue(ht.contains(chr(19)))
     self.assertFalse(ht.contains(chr(20)))