コード例 #1
0
    def test_clear(self):
        d = HashTable(upper_to_i.items(),
                      key_type=ctypes.c_char_p,
                      value_type=ctypes.c_int)

        d.clear()
        self.assertEqual(len(d), 0)

        d.update(upper_to_i)
        self.assertEqual(len(d), len(upper_to_i))
コード例 #2
0
    def test_clear(self):
        table = HashTable()

        table['table'] = 1
        table['will'] = 2
        table['be'] = 3
        table['cleared'] = 4

        table.clear()

        assert table.size == 0
        for node in table.table:
            assert node is None

        table.clear()

        assert table.size == 0
        for node in table.table:
            assert node is None

        table['one'] = 1

        table.clear()

        assert table.size == 0
        for node in table.table:
            assert node is None