コード例 #1
0
def test_insert():
    test = pq.priorityqueue()
    test.insert(1, "hello")
    test.insert(2, "I")
    test.insert(3, "am")
    test.insert(4, "in")
    test.insert(5, "order")
    result = ''
    keys = sorted(test.items.keys())
    for k in keys:
        result = result + test.items[k][0]
    result = result.strip()
    assert result == "helloIaminorder"
コード例 #2
0
def test_insert():
    test = pq.priorityqueue()
    test.insert(1, "hello")
    test.insert(2, "I")
    test.insert(3, "am")
    test.insert(4, "in")
    test.insert(5, "order")
    result = ''
    keys = sorted(test.items.keys())
    for k in keys:
        result = result + test.items[k][0] 
    result = result.strip()
    assert result == "helloIaminorder"
コード例 #3
0
def test_pop():
    test = pq.priorityqueue()
    test.insert(1, "hello")
    test.insert(2, "I")
    test.insert(3, "am")
    test.insert(4, "in")
    test.insert(5, "order")
    val = test.pop()
    assert val == "hello"
    val = test.pop()
    assert val == "I"
    val = test.pop()
    assert val == "am"
    val = test.pop()
    assert val == "in"
    val = test.pop()
    assert val == "order"
コード例 #4
0
def test_pop():
    test = pq.priorityqueue()
    test.insert(1, "hello")
    test.insert(2, "I")
    test.insert(3, "am")
    test.insert(4, "in")
    test.insert(5, "order") 
    val = test.pop()
    assert val == "hello"
    val = test.pop()
    assert val == "I"
    val = test.pop()
    assert val == "am"
    val = test.pop()
    assert val == "in"
    val = test.pop()
    assert val == "order"
コード例 #5
0
def test_multivalues():
    test = pq.priorityqueue()
    test.insert(1, "first")
    test.insert(1, "second")
    return test.pop()
コード例 #6
0
def test_peek():
    test = pq.priorityqueue()
    test.insert(6, "six")
    retval = test.peek()
    assert retval == 6
コード例 #7
0
def test_constructor():
    test = pq.priorityqueue()
    assert test.items == {}
コード例 #8
0
def test_multivalues():
    test = pq.priorityqueue()
    test.insert(1, "first")
    test.insert(1, "second")
    return test.pop()
コード例 #9
0
def test_peek():
    test = pq.priorityqueue()
    test.insert(6, "six")
    retval = test.peek()
    assert retval == 6
コード例 #10
0
def test_constructor():
    test = pq.priorityqueue()
    assert test.items == {}