Пример #1
0
 def testpushmultiple(self):
     n = StackNode(12)
     n2 = StackNode(10)
     s = Stack(n)
     s.push(n2)
     self.assertTrue(s.top is not None)
     self.assertTrue(s.top.data == 10)
     self.assertTrue(s.size() == 2)
Пример #2
0
 def testpop(self):
     n2 = StackNode(12)
     n = StackNode(10)
     s = Stack(n)
     s.push(n2)
     n = s.pop()
     self.assertTrue(s.top is not None)
     self.assertTrue(s.top.data == 10)
     self.assertTrue(n.data == 12)
Пример #3
0
 def testsize(self):
     n2 = StackNode(12)
     n = StackNode(10)
     s = Stack(n)
     s.push(n2)
     self.assertTrue(s.size() == 2)
     s.pop()
     self.assertTrue(s.size() == 1)
Пример #4
0
    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)
Пример #5
0
 def testisEmpty(self):
     n2 = StackNode(12)
     n = StackNode(10)
     s = Stack(n)
     s.push(n2)
     n = s.pop()
     self.assertFalse(s.isEmpty())
     n = s.pop()
     self.assertTrue(n.data == 10)
     self.assertTrue(s.isEmpty())
Пример #6
0
    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)
Пример #7
0
 def testsize(self):
     threshold = 3
     top = StackNode(10)
     s = Stack(top)
     sos = SetOfStacks(s, threshold)
     self.assertTrue(sos.size() == 1)
Пример #8
0
 def testpushsingle(self):
     n = StackNode(10)
     s = Stack(n)
     self.assertTrue(s.top is not None)
     self.assertTrue(s.top.data == 10)
     self.assertTrue(s.size() == 1)