Esempio n. 1
0
    def test_infoElements(self):
        """
        """
        self.queue = q.newQueue(self.list_type)
        self.assertEqual(q.size(self.queue), 0)
        self.assertTrue(q.isEmpty(self.queue))
        q.enqueue(self.queue, self.movie5)
        q.enqueue(self.queue, self.movie6)
        q.enqueue(self.queue, self.movie3)
        q.enqueue(self.queue, self.movie10)
        q.enqueue(self.queue, self.movie1)
        q.enqueue(self.queue, self.movie2)
        q.enqueue(self.queue, self.movie8)
        q.enqueue(self.queue, self.movie4)
        q.enqueue(self.queue, self.movie7)
        q.enqueue(self.queue, self.movie9)

        elem = q.dequeue(self.queue)
        self.assertEqual(q.size(self.queue), 9)
        self.assertDictEqual(elem, self.movie5)

        elem = q.dequeue(self.queue)
        self.assertEqual(q.size(self.queue), 8)
        self.assertDictEqual(elem, self.movie6)

        elem = q.peek(self.queue)
        self.assertEqual(q.size(self.queue), 8)
        self.assertDictEqual(elem, self.movie3)

        q.enqueue(self.queue, self.movie5)
        self.assertEqual(q.size(self.queue), 9)

        elem = q.peek(self.queue)
        self.assertDictEqual(elem, self.movie3)
Esempio n. 2
0
    def test_infoElements (self):
        """
        """
        self.queue = q.newQueue(self.list_type)
        self.assertEqual (q.size(self.queue), 0)
        self.assertTrue (q.isEmpty(self.queue))
        q.enqueue  (self.queue, self.book5)
        q.enqueue  (self.queue, self.book6)
        q.enqueue  (self.queue, self.book3)
        q.enqueue  (self.queue, self.book10)
        q.enqueue  (self.queue, self.book1)
        q.enqueue  (self.queue, self.book2)
        q.enqueue  (self.queue, self.book8)
        q.enqueue  (self.queue, self.book4)
        q.enqueue  (self.queue, self.book7)
        q.enqueue  (self.queue, self.book9)

        elem = q.dequeue (self.queue)
        self.assertEqual (q.size(self.queue), 9)
        self.assertDictEqual (elem, self.book5)

        elem = q.dequeue (self.queue)
        self.assertEqual (q.size(self.queue), 8)
        self.assertDictEqual (elem, self.book6)

        elem = q.peek (self.queue)
        self.assertEqual (q.size(self.queue), 8)
        self.assertDictEqual (elem, self.book3)

        q.enqueue  (self.queue, self.book5)
        self.assertEqual (q.size(self.queue), 9)
        
        elem = q.peek (self.queue)
        self.assertDictEqual (elem, self.book3)
Esempio n. 3
0
def test_peek_dequeue():
    """
    Este test prueba la creacion de una cola y que el orden de salida sea el correcto para la
    estructura en cuestion, y que el tamaño se reduzca para cada salida de objeto
    """

    queue = q.newQueue(list_type)
    assert q.size(queue) == 0
    assert q.isEmpty(queue)
    queue = q.newQueue(list_type)

    q.enqueue(queue, book5)
    q.enqueue(queue, book6)
    q.enqueue(queue, book3)
    q.enqueue(queue, book10)
    q.enqueue(queue, book1)
    q.enqueue(queue, book2)
    q.enqueue(queue, book8)
    q.enqueue(queue, book4)
    q.enqueue(queue, book7)
    q.enqueue(queue, book9)
    total = q.size(queue)
    while not (q.isEmpty(queue)):
        peek = q.peek(queue)
        assert (q.dequeue(queue) == peek)
        total -= 1
        assert (total == q.size(queue))
Esempio n. 4
0
def test_infoElements():
    """
    Este test busca confirmar que los datos se almacenen de forma correcta y que
    sean los valores correctos en el orden apropiado de la estructura.
    """
    queue = q.newQueue(list_type)
    assert (q.size(queue) == 0)
    assert (q.isEmpty(queue))
    queue = q.newQueue(list_type)

    q.enqueue(queue, book5)
    q.enqueue(queue, book6)
    q.enqueue(queue, book3)
    q.enqueue(queue, book10)
    q.enqueue(queue, book1)
    q.enqueue(queue, book2)
    q.enqueue(queue, book8)
    q.enqueue(queue, book4)
    q.enqueue(queue, book7)
    q.enqueue(queue, book9)

    elem = q.peek(queue)
    assert (q.size(queue) == 10)
    assert (elem == book5)

    elem = q.dequeue(queue)
    assert (q.size(queue) == 9)
    assert (elem == book5)

    elem = q.dequeue(queue)
    assert (q.size(queue) == 8)
    assert (elem == book6)

    elem = q.peek(queue)
    assert (q.size(queue) == 8)
    assert (elem == book3)

    q.enqueue(queue, book9)
    assert (q.size(queue) == 9)
    elem = q.peek(queue)
    assert (elem == book3)
Esempio n. 5
0
def test_enqueue_dequeue():
    """
    Este test prueba que la cola pueda manejar inserciones y eliminaciones de forma correcta siguiendo
    un orden establecido, y que no quede referencia al objeto sacado despues de haberlo removido de la
    cola
    """
    queue = q.newQueue(list_type)
    assert (q.size(queue) == 0)
    assert (q.isEmpty(queue))

    q.enqueue(queue, book5)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book6)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book3)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book10)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book1)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book2)
    assert (q.size(queue) == 1)
    assert (q.peek(queue) == q.dequeue(queue))
    assert (q.size(queue) == 0)

    q.enqueue(queue, book8)
    q.enqueue(queue, book4)
    q.enqueue(queue, book7)
    q.enqueue(queue, book9)

    assert (q.size(queue) == 4)
    assert book8 == q.dequeue(queue)
    assert book4 == q.dequeue(queue)
    assert book7 == q.dequeue(queue)
    assert book9 == q.dequeue(queue)

    assert (q.size(queue) == 0)