def test_stacks_dequeue_multiple():
    queue = PseudoQueue()
    queue.enqueue(1)
    queue.enqueue(2)
    queue.enqueue(3)
    queue.dequeue()
    queue.dequeue()
    assert queue.secound_stack.top.value == 3
    assert queue.secound_stack.top.next == None
コード例 #2
0
def test_PseudoQueue_dequeue_multi():
    new_psQ = PseudoQueue()
    new_psQ.enqueue(3)
    new_psQ.enqueue(6)
    new_psQ.enqueue(9)
    new_psQ.enqueue(4)
    new_psQ.enqueue(7)
    new_psQ.enqueue(10)
    new_psQ.dequeue()
    new_psQ.dequeue()
    new_psQ.dequeue()
    assert new_psQ.__str__() == '{10} -> {7} -> {4} -> '
コード例 #3
0
def test_enqueue_dequeue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.stack1.peek() == 10
    pseudo_q.enqueue('cat')
    assert pseudo_q.stack1.peek() == 'cat'
    pseudo_q.enqueue('dog')
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'a'
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'b'
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'c'
    assert pseudo_q.dequeue() == 10
    assert pseudo_q.dequeue() == 'cat'
    assert pseudo_q.dequeue() == 'dog'
コード例 #4
0
def test_PseudoQueue_dequeue():
    new_psQ = PseudoQueue()
    new_psQ.enqueue(3)
    new_psQ.enqueue(6)
    new_psQ.enqueue(9)
    new_psQ.enqueue(4)
    new_psQ.enqueue(7)
    new_psQ.enqueue(10)
    assert new_psQ.dequeue() == 3
def test_failure_case():
    pseudo_q = PseudoQueue()
    assert pseudo_q.dequeue() == "PseudoQueue is empty"
コード例 #6
0
def test_dequeue_empty():
    pseudo_q = PseudoQueue(Stack())
    with pytest.raises(Exception):
        result = pseudo_q.dequeue()
コード例 #7
0
def test_dequeue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.dequeue() == 'a'
コード例 #8
0
def test_PseudoQueue_dequeue_faliure_case():
    new_psQ = PseudoQueue()
    assert new_psQ.dequeue() == "stack is empty!"
コード例 #9
0
def test_dequeue():
    queue = PseudoQueue()
    queue.enqueue(5)
    assert queue.dequeue() == 5