Beispiel #1
0
 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])
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
 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")
Beispiel #5
0
 def testEmpty(self):
     s = Stack()
     self.assertTrue(s.isEmpty())
     s.add("Stuff")
     self.assertFalse(s.isEmpty())
Beispiel #6
0
 def testSize(self):
     s = Stack()
     s.add("1")
     self.assertTrue(s.size() == 1)
     s.remove()
     self.assertFalse(s.size() == 1)
Beispiel #7
0
 def testRemove(self):
     s = Stack()
     s.add("1")
     s.add("2")
     s.remove()
     self.assertTrue(s.size() == 1)
Beispiel #8
0
 def testAdd(self):
     s = Stack()
     s.add("1")
     s.add("2")
     self.assertTrue(s.size() == 2)