def test_push_several_and_pop_one(self): self.add_elem(new_edge()) self.assertEqual(bool(self.instance), True) self.add_elem(new_edge()) self.assertEqual(bool(self.instance), True) self.remove_elem() self.assertEqual(bool(self.instance), True)
def test_insert_several_and_remove_one(self): self.add_elem(new_edge()) self.assert_emptiness(1) self.add_elem(new_edge()) self.assert_emptiness(2) self.remove_elem() self.assert_emptiness(1)
def test_minimum_returns_a_copy(self): self.add_elem(new_edge()) elem1 = self.get_elem() elem2 = self.get_elem() self.assertNotEqual(elem1.c_address, elem2.c_address)
def test_insert_twice(self): e = new_edge() self.add_elem(e) f = e.copy() assert e == f self.add_elem(f) self.assertEqual(self.get_elem(), f) self.remove_elem() self.assertEqual(self.get_elem(), e) self.remove_elem() self.assert_emptiness(0)
def test_push_twice(self): e = new_edge() self.add_elem(e) f = e.copy() assert e == f self.add_elem(f) self.assertEqual(self.get_elem(), f) self.remove_elem() self.assertEqual(self.get_elem(), e) self.remove_elem() self.assertEqual(bool(self.instance), False)
def test_push_and_pop_all(self): seq = self.gen_seq(100) edges = [] for i in seq: e = new_edge(i) self.add_elem(e) edges.append(e) self.assertEqual(bool(self.instance), True) # remove them all, assert order and identity for i in seq: self.assertEqual(self.get_elem(), edges.pop()) self.remove_elem() self.assertEqual(bool(self.instance), False)
def _test_insert_and_remove_all(self, seq): self.assert_emptiness(0) edges = [] for j, i in enumerate(seq): e = new_edge(i) self.add_elem(e) edges.append(e) self.assert_emptiness(j + 1) # remove them all, assert order and identity edges.sort(reverse=True) size = len(seq) for j in xrange(size, 0, -1): e = edges.pop() self.assertEqual(self.get_elem(), e) self.remove_elem() self.assert_emptiness(j - 1) self.assert_emptiness(0)
def test_insert_max_size(self): seq = self.gen_seq(MAX_SIZE) for i in seq: self.add_elem(new_edge(i)) self.assert_emptiness(MAX_SIZE)
def test_insert(self): self.add_elem(new_edge()) self.assert_emptiness(1)
def add_from_sequence(self, sequence): for i in sequence: assert 0 < i assert i <= MAX_SIZE self.add_elem(new_edge(i))
def test_push(self): self.add_elem(new_edge()) self.assertEqual(bool(self.instance), True)
def add_from_sequence(self, sequence): for i in sequence: self.add_elem(new_edge(i))