def test_stacks_enqueue_multiple(): queue = PseudoQueue() queue.enqueue(1) queue.enqueue(2) queue.enqueue(3) assert queue.first_stack.top.value == 3 assert queue.first_stack.top.next.value == 2 assert queue.first_stack.top.next.next.value == 1
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
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'
def test_PseudoQueue_enqueue(): 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.__str__() == '{10} -> {7} -> {4} -> {9} -> {6} -> {3} -> '
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_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} -> '
def test_happy_path(): pseudo_q = PseudoQueue() pseudo_q.enqueue(20) pseudo_q.enqueue(15) pseudo_q.enqueue(10) pseudo_q.enqueue(5) actual = pseudo_q.en.__str__() expected = '5-> 10-> 15-> 20-> None' assert expected == actual
def test_edge_case(): pseudo_q = PseudoQueue() assert pseudo_q.enqueue(None) == "Not a valid input"
def fixed_pseudoQueue(): pq = PseudoQueue() pq.enqueue(1) pq.enqueue(2) pq.enqueue(3) return pq
def test_enqueue_empty_stack(): pseudo_q = PseudoQueue(Stack()) pseudo_q.enqueue('cat') assert pseudo_q.stack1.peek() == 'cat'
def test_enqueue(my_stack): pseudo_q = PseudoQueue(my_stack) pseudo_q.enqueue('cat') assert pseudo_q.stack1.peek() == 'cat'
def test_PseudoQueue_enqueue_multi(): new_psQ = PseudoQueue() new_psQ.enqueue(3, 6, 9, 4, 7, 10) assert new_psQ.__str__() == '{10} -> {7} -> {4} -> {9} -> {6} -> {3} -> '
def test_stacks_enqueue(): queue = PseudoQueue() queue.enqueue(1) assert queue.first_stack.top.value == 1
def test_dequeue(): queue = PseudoQueue() queue.enqueue(5) assert queue.dequeue() == 5
def test_enqueue(): queue = PseudoQueue() queue.enqueue(5) assert queue.__str__() == 'Rear -> {5} -> Front'
def test_unvalid_input_to_pseudo_queue(): pseudo_queue = PseudoQueue() assert pseudo_queue.enqueue(None) == 'Not a valid input'