예제 #1
0
def test_initialize_with_single_tuple():
    """The test initializes priority q with a single tuple."""
    from priorityq import PriorityQ
    new_pq = PriorityQ((3, 2))
    assert len(new_pq) == 1
    assert new_pq._high_p == 2
    assert new_pq.peek() == 3
예제 #2
0
def test_peek():
    """Test that peeking reveals the root of the priority queue."""
    from priorityq import PriorityQ
    push_list = [(2, 'maintenance'), (1, 'staff mtg'), (1, 'stand-up'),
                 (0, 'server crash'), (0, 'boss DUI')]

    test_q = PriorityQ()
    for pri, val in push_list:
        test_q.insert(pri, val)

    assert test_q.peek() == 'server crash'
예제 #3
0
 def test_peek_with_1_elem(self):
     pri1, val1 = 2, 'a'
     pri2, val2 = 5, 'b'
     pri3, val3 = 1, 'c'
     pri4, val4 = 4, 'd'
     pri5, val5 = 3, 'e'
     testq = PriorityQ()
     testq.insert(pri1, val1)
     testq.insert(pri2, val2)
     testq.insert(pri3, val3)
     testq.insert(pri4, val4)
     testq.insert(pri5, val5)
     x = testq.peek()
     self.assertEquals(x, 'c')
def test_peek():
    """Test that peeking reveals the root of the priority queue."""
    from priorityq import PriorityQ
    push_list = [(2, 'maintenance'),
                 (1, 'staff mtg'),
                 (1, 'stand-up'),
                 (0, 'server crash'),
                 (0, 'boss DUI')]

    test_q = PriorityQ()
    for pri, val in push_list:
        test_q.insert(pri, val)

    assert test_q.peek() == 'server crash'