예제 #1
0
 def test_many_pops(self):
     ss = StackSet()
     self.fill_stack(ss, 10000)
     for i in xrange(0, 9000):
         ss.pop()
     assert len(ss) == 1000
     assert ss.peek() == 999
예제 #2
0
 def test_push_into_empty(self):
     ss = StackSet()
     ss.push('hi')
     assert len(ss) == 1
     assert ss.peek() == 'hi'
     k = ss.pop()
     assert len(ss) == 0
     assert k == 'hi'
예제 #3
0
 def test_push_multiple_replace_multiple(self):
     ss = StackSet()
     self.fill_stack(ss, 100)
     ss.push(5)
     ss.push(50)
     ss.push(55)
     ss.push(105)
     assert 5 in ss
     assert 50 in ss
     assert 55 in ss
     assert 105 in ss
     assert len(ss) == 101
     assert ss.peek() == 105
예제 #4
0
 def test_empty_repr(self):
     ss = StackSet()
     assert ss.peek() is None
     assert repr(ss) == 'StackSet([])'
예제 #5
0
 def test_str(self):
     ss = StackSet()
     self.fill_stack(ss, 5)
     assert ss.peek() == 4
     assert str(ss) == '[0, 1, 2, 3, 4]'
예제 #6
0
 def test_cons3(self):
     ss = StackSet([1,2,3,4,5])
     assert len(ss) == 5
     assert ss.peek() == 5
예제 #7
0
 def test_cons1(self):
     ss = StackSet()
     assert len(ss) == 0
     assert ss.peek() is None