コード例 #1
0
def test_dequeue():
    q = MyQueue()
    q.enqueue(1)
    q.enqueue(2)
    assert 2 == q.size()
    assert 1 == q.dequeue()
    assert 1 == q.size()
    assert 2 == q.dequeue()
    assert 0 == q.size()
    assert 1 == q.isEmpty()
コード例 #2
0
def test_size():
    q = MyQueue()
    q.enqueue(1)
    q.enqueue(2)
    q.enqueue(3)
    assert 3 == q.size()
    q.enqueue(4)
    assert 4 == q.size()
    q.dequeue()
    q.dequeue()
    q.dequeue()
    assert 1 == q.size()
コード例 #3
0
def test_enqueue():
    q = MyQueue()
    assert 2 == q.enqueue(2)
    assert 1 == q.size()
    assert 5 == q.enqueue(5)
    assert 2 == q.size()