Пример #1
0
 def test_copy(self):
     ss = StackSet([1,3,5,7])
     ss2 = ss.copy()
     assert len(ss2) == 4
     ss.push(9)
     assert len(ss) == 5
     assert len(ss2) == 4
Пример #2
0
 def test_push_one_thing_twice(self):
     ss = StackSet()
     ss.push('pokey')
     ss.push('pokey')
     assert len(ss) == 1
     k = ss.pop()
     assert k == 'pokey'
     assert len(ss) == 0
Пример #3
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'
Пример #4
0
 def test_push_multiple_replace_one(self):
     ss = StackSet()
     self.fill_stack(ss, 20)
     assert len(ss) == 20
     ss.push(15)
     assert len(ss) == 20
     k = ss.pop()
     assert k == 15
     assert len(ss) == 19
Пример #5
0
 def test_push_two(self):
     ss = StackSet()
     ss.push('a')
     ss.push('b')
     assert len(ss) == 2
     k = ss.pop()
     assert k == 'b'
     assert len(ss) == 1
     k = ss.pop()
     assert k == 'a'
     assert len(ss) == 0
Пример #6
0
 def test_clear(self):
     ss = StackSet()
     ss.push(3)
     ss.push(5)
     ss.clear()
     assert len(ss) == 0
     ss.push(1)
     ss.push(9)
     assert len(ss) == 2
     ss.clear()
     assert len(ss) == 0
     assert not 3 in ss
     assert not 5 in ss
     assert not 1 in ss
     assert not 9 in ss
Пример #7
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