def testpop(self): threshold = 3 s = Stack(StackNode(10)) sos = SetOfStacks(s, threshold) sos.push(StackNode(11)) sos.push(StackNode(12)) sos.push(StackNode(13)) n = sos.pop() self.assertEqual(n.data, 13) self.assertEqual(sos.size(), 1)
class TestStackMin(unittest.TestCase): def setUp(self): self.stack = SetOfStacks(5) def test_push_and_peek(self): for i in range(10): self.stack.push(i) self.assertEquals(self.stack.peek(), i) def test_push_and_pop(self): for i in range(10): self.stack.push(i) for i in range(9, -1, -1): self.assertEquals(self.stack.pop(), i)
def testpush(self): threshold = 3 top = StackNode(10) s = Stack(top) sos = SetOfStacks(s, threshold) top = StackNode(11) sos.push(top) top = StackNode(12) sos.push(top) self.assertEqual(sos.size(), 1) top = StackNode(13) sos.push(top) self.assertEqual(s.size(), 3) self.assertEqual(sos.size(), 2)