-
Notifications
You must be signed in to change notification settings - Fork 0
/
testStack.py
35 lines (31 loc) · 937 Bytes
/
testStack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
import stack
class TestStack( unittest.TestCase ):
def setUp(self):
"""
Just create an empty stack
"""
self.stack = stack.Stack()
def testEmptySize(self):
"""
Check that an empty stack always has size 0
"""
self.assertEqual(0,len(self.stack)) # Should be 0
self.stack.push("val")
self.stack.pop()
self.assertEqual(0,len(self.stack)) # Should still be 0
try:
self.stack.pop()
except:
pass
self.assertEqual(0,len(self.stack)) # It's 0 even after an error
def testSize(self):
"""
Test that the size remains sane
"""
self.assert_(0 == len(self.stack))
for i in range(1,10,1):
self.stack.push(i)
self.assertEqual(len(self.stack),i)
if (__name__=="__main__"):
unittest.main()