Esempio n. 1
0
 def test_addLast(self):
     self.lst = slt.newList('ARRAY_LIST')
     slt.addLast(self.lst, self.book1)
     self.assertEqual(slt.size(self.lst), 1)
     slt.addLast(self.lst, self.book2)
     self.assertEqual(slt.size(self.lst), 2)
     book = slt.firstElement(self.lst)
     self.assertDictEqual(book, self.book1)
     book = slt.lastElement(self.lst)
     self.assertDictEqual(book, self.book2)
 def test_addLast (self):
     self.lst = slt.newList()
     self.assertEqual (slt.isEmpty(self.lst), True)
     self.assertEqual (slt.size(self.lst), 0)
     slt.addLast (self.lst, self.book1)
     self.assertEqual (slt.size(self.lst), 1)
     slt.addLast (self.lst, self.book2)
     self.assertEqual (slt.size(self.lst), 2)
     book = slt.firstElement(self.lst)
     self.assertDictEqual (book, self.book1)
     book = slt.lastElement(self.lst)
     self.assertDictEqual (book, self.book2)
Esempio n. 3
0
 def test_addLast(self):
     self.lst = slt.newList('ARRAY_LIST')
     self.assertEqual(slt.isEmpty(self.lst), True)
     self.assertEqual(slt.size(self.lst), 0)
     slt.addLast(self.lst, self.movie1)
     self.assertEqual(slt.size(self.lst), 1)
     slt.addLast(self.lst, self.movie2)
     self.assertEqual(slt.size(self.lst), 2)
     movie = slt.firstElement(self.lst)
     self.assertDictEqual(movie, self.movie1)
     movie = slt.lastElement(self.lst)
     self.assertDictEqual(movie, self.movie2)
Esempio n. 4
0
def lastElement(lst):
    """ Retorna el último elemento de una  lista no vacia.  No se elimina el elemento.

    Args:
        lst: La lista a examinar

    Raises:
        Exception
    """
    try:
        return lt.lastElement(lst)
    except Exception as exp:
        error.reraise(exp, 'TADList->LastElement: ')
Esempio n. 5
0
def lastElement(lst):
    """
    Retorna el último elemento de la lista, sin eliminarlo.
    """
    return lt.lastElement(lst)