def test_add(self): new_stack = Stack() new_stack.add(5) new_stack.add(10) new_stack.add(20) result = new_stack.return_data() self.assertEqual(result, [5, 10, 20])
def test_empty(self): new_stack = Stack() new_stack.add(60) result_not_empty = new_stack.is_empty() self.assertTrue(result_not_empty) new_stack.remove() result_empty = new_stack.is_empty() self.assertFalse(result_empty)
def test_peek(self): new_stack = Stack() new_stack.add(5) new_stack.add(10) self.assertIs(new_stack.peek(), 10) new_stack.add(20) self.assertIs(new_stack.peek(), 20)
def testLastelement(self): s = Stack() s.add("Andy") self.assertTrue(s.check_last_item() == "Andy") s.add("Pignanelli") self.assertTrue(s.check_last_item() == "Pignanelli")
def testEmpty(self): s = Stack() self.assertTrue(s.isEmpty()) s.add("Stuff") self.assertFalse(s.isEmpty())
def testSize(self): s = Stack() s.add("1") self.assertTrue(s.size() == 1) s.remove() self.assertFalse(s.size() == 1)
def testRemove(self): s = Stack() s.add("1") s.add("2") s.remove() self.assertTrue(s.size() == 1)
def testAdd(self): s = Stack() s.add("1") s.add("2") self.assertTrue(s.size() == 2)