Пример #1
0
    def test_delete_some(self):
        t = LinearProbingHashTable()
        ls = [(1, 3), (5, "two"), (2.72, 10), ("one", 3.14), (1, "seven")]

        for k, v in ls:
            t.put(k, v)

        self.assertEqual(t.size, 4)
        self.assertEqual(t.delete(1), "seven")
        self.assertEqual(t.delete(2.72), 10)
        self.assertEqual(t.size, 2)
Пример #2
0
    def test_delete_all(self):
        t = LinearProbingHashTable()
        ls = gen_rand_list_of_distinct_ascii_and_numbers()
        for elem in ls:
            t.put(elem, elem)

        self.assertEqual(t.size, len(ls))

        for key in ls:
            self.assertEqual(t.delete(key), key)

        self.assertEqual(t.size, 0)
Пример #3
0
 def test_delete_key_not_present(self):
     t = LinearProbingHashTable()
     t.put(-10, "testing deletion when key not in the table")
     self.assertIsNone(t.delete(7))
Пример #4
0
 def test_delete_empty_table(self):
     t = LinearProbingHashTable()
     self.assertIsNone(t.delete(3))