예제 #1
0
def linked_list_test_26():
    s = "Hago pop del primer elemento de la lista"
    try:
        test_list = LinkedList()
        value_1 = 1
        value_2 = "January"
        value_3 = (1970)
        append(test_list, value_1)
        append(test_list, value_2)
        append(test_list, value_3)
        test_element = test_list.pop(0)

        def custom_test():
            try:
                if check_list_integrity(test_list, 2):
                    return ""
                return errors["integrity"]
            except Exception:
                return errors["integrity"]

        def custom_test2():
            try:
                if check_list_is_correct(
                        test_list.prim, value_2,
                    [value_2, value_3]) and test_element == value_1:
                    return ""
                return errors["assert"]
            except Exception:
                return errors["assert"]

        test.print_test(s, test_runner(custom_test(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #2
0
def linked_list_test_24():
    s = "Hago remove del ultimo elemento de la lista"
    try:
        test_list = LinkedList()
        value_1 = 1
        value_2 = "January"
        value_3 = (1970)
        append(test_list, value_1)
        append(test_list, value_2)
        append(test_list, value_3)
        test_list.remove(value_3)

        def custom_test1():
            try:
                if not check_list_is_correct(test_list.prim, value_1,
                                             [value_1, value_2]):
                    return errors["assert"]
                return ""
            except Exception:
                return errors["assert"]

        def custom_test2():
            try:
                if not check_list_integrity(test_list, 2):
                    return errors["integrity"]
                return ""
            except Exception:
                return errors["integrity"]

        test.print_test(s, test_runner(custom_test1(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #3
0
def linked_list_test_40():
    s = "Pruebo hacer 8 inserts uno detras del otro e inserto en la segunda posicion"
    value_1 = "Boomer"
    value_2 = "Ok"
    try:
        test_list = LinkedList()
        many_insert(test_list, value_2, 8)
        test_list.insert(1, value_1)
        correct_list = []
        for i in range(0, 9):
            if i == 1:
                correct_list.append(value_1)
            else:
                correct_list.append(value_2)

        def custom_test():
            if check_list_is_correct(test_list.prim, value_2, correct_list):
                return ""
            return errors["assert"]

        def custom_test2():
            if check_list_integrity(test_list, 9):
                return ""
            return errors["integrity"]

        test.print_test(s, test_runner(custom_test(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #4
0
def linked_list_test_13():
    s = "Pruebo hacer un pop valido sin indice"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        append(test_list, value_1)
        append(test_list, value_2)
        test_value_1 = test_list.pop()
        test_value_3 = test_list.pop()

        def custom_test1():
            try:
                if value_2 == test_value_1 and value_1 == test_value_3:
                    return ""
                return errors["assert"]
            except Exception:
                return errors["assert"]

        def custom_test2():
            try:
                integrity = check_list_integrity(test_list, 0)
                if integrity:
                    return ""
                return errors["integrity"]
            except Exception:
                return errors["integrity"]

        test.print_test(s, test_runner(custom_test1(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #5
0
def linked_list_test_17():
    s = "Pruebo hacer remove de un elemento que no existe"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 10)
        append(test_list, value_2)
        error_was_thrown = False
        try:
            test_list.remove("ESTE TEXTO NO ESTA")
        except ValueError as err:
            error_was_thrown = True

        def custom_test():
            if error_was_thrown:
                return ""
            return errors["assert"]

        def custom_test1():
            try:
                if check_list_integrity(test_list, 11):
                    return ""
                return errors["integrity"]
            except Exception:
                return errors["integrity"]

        test.print_test(s, error_was_thrown)
    except Exception as err:
        error_by_except(s, err)
예제 #6
0
def linked_list_test_21():
    s = "Checkeo que la lista enlazada termina con None despues de hacer un append"
    try:
        test_list = LinkedList()
        test_list.append("JAJA")
        test.print_test(s, test_list.prim.next is None)
    except Exception as err:
        error_by_except(s, err)
예제 #7
0
def linked_list_test_44():
    s = "Pruebo hacer un index de una lista con elementos repetidos"
    value_1 = "Senna"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 10)
        indice = test_list.index(value_1)
        test.print_test(s, indice == 0)
    except Exception as err:
        error_by_except(s, err)
예제 #8
0
def linked_list_test_48():
    s = "Pruebo hacer un length despues de haber borrado un elemento (pop(0))"
    value_1 = "hue"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 9)
        test_list.pop(0)
        test.print_test(s, test_runner(length(test_list, 8)))
    except Exception as err:
        error_by_except(s, err)
예제 #9
0
def linked_list_test_36():
    s = "Pruebo hacer 5000 remove"
    value_1 = "is"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 5000)
        for i in range(0, 5000):
            test_list.remove(value_1)
        test.print_test(s, test_runner(length(test_list, 0)))
    except Exception as err:
        error_by_except(s, err)
예제 #10
0
def linked_list_test_10():
    s = "Pruebo insertar un elemento fuera de rango"
    try:
        test_list = LinkedList()
        error_was_thrown = False
        try:
            test_list.insert(2, "BLAZE IT")
        except IndexError as err:
            error_was_thrown = True
        test.print_test(s, error_was_thrown)
    except Exception as err:
        error_by_except(s, err)
예제 #11
0
def linked_list_test_11():
    s = "Pruebo hacer un pop de una lista vacia"
    try:
        test_list = LinkedList()
        error_was_thrown = False
        try:
            test_list.pop()
        except IndexError as err:
            error_was_thrown = True
        test.print_test(s, error_was_thrown)
    except Exception as err:
        error_by_except(s, err)
예제 #12
0
def linked_list_test_15():
    s = "Pruebo hacer un index de un elemento que existe"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 10)
        append(test_list, value_2)
        index_1 = test_list.index(value_1)
        index_2 = test_list.index(value_2)
        test.print_test(s, index_1 == 0 and index_2 == 10)
    except Exception as err:
        error_by_except(s, err)
예제 #13
0
def linked_list_test_27():
    s = "Hago un index de una lista de 1000 elementos"
    try:
        test_list = LinkedList()
        value_1 = "!"
        value_2 = "F"
        many_append(test_list, value_1, 999)
        append(test_list, value_2)
        correct_index = 999
        test_index = test_list.index(value_2)
        test.print_test(s, test_index == correct_index)
    except Exception as err:
        error_by_except(s, err)
예제 #14
0
def linked_list_test_20():
    s = "Hago varias operaciones (6 inserts uno detras del otro, 1 remove, 1 pop con indice, 2 pop sin indice, un length y un index)"
    value_1 = "Some"
    value_2 = "Body"
    value_3 = "Once"
    try:
        test_list = LinkedList()
        many_insert(test_list, value_1, 2)
        many_insert(test_list, value_2, 2)
        many_insert(test_list, value_3, 2)
        test_list.remove(value_3)
        test_list.pop(1)
        test_list.pop()
        test_element = test_list.pop()

        def custom_test2():
            if not check_list_integrity(test_list, 2):
                return errors["integrity"]
            return ""

        def custom_test():
            return "" if (value_2 == test_element) else errors["assert"]

        result = test_runner(custom_test(), length(test_list, 2),
                             index(test_list, value_2, 1), custom_test2())
        test.print_test(s, result)
    except Exception as err:
        error_by_except(s, err)
예제 #15
0
def linked_list_test_12():
    s = "Pruebo hacer demasiados pops"
    try:
        test_list = LinkedList()
        many_append(test_list, "El 8N en la pera", 5)
        error_was_thrown = False
        try:
            for i in range(6):
                test_list.pop()
        except IndexError as err:
            error_was_thrown = True
        test.print_test(s, error_was_thrown)
    except Exception as err:
        error_by_except(s, err)
예제 #16
0
def linked_list_test_16():
    s = "Pruebo hacer un index de un elemento que no existe"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 10)
        append(test_list, value_2)
        was_error_thrown = False

        index = test_list.index("El 8N es la fiesta de gestion de tic")
        was_error_thrown = not index
        test.print_test(s, was_error_thrown)
    except Exception as err:
        error_by_except(s, err)
예제 #17
0
def linked_list_test_25():
    s = "Hago remove del primer elemento de la lista"
    try:
        test_list = LinkedList()
        value_1 = 1
        value_2 = "January"
        value_3 = (1970)
        append(test_list, value_1)
        append(test_list, value_2)
        append(test_list, value_3)
        test_list.remove(value_1)
        test.print_test(
            s,
            check_list_is_correct(test_list.prim, value_2, [value_2, value_3]))
    except Exception as err:
        error_by_except(s, err)
예제 #18
0
def linked_list_test_43():
    s = "Pruebo hacer remove dentro de una lista con elementos repetidos"
    value_1 = "Yas"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 9)
        test_list.remove(value_1)

        def custom_test():
            if check_list_integrity(test_list, 8):
                return ""
            return errors["integrity"]

        test.print_test(s, test_runner(custom_test()))
    except Exception as err:
        error_by_except(s, err)
예제 #19
0
def linked_list_test_14():
    s = "Pruebo hacer un pop valido con indice"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        append(test_list, "ELEMENTO SORPRESA")
        append(test_list, value_1)
        append(test_list, value_2)
        test_value_1 = test_list.pop(1)
        test_value_2 = test_list.pop(1)
        integrity = check_list_integrity(test_list, 1)
        test.print_test(
            s, value_1 == test_value_1 and value_2 == test_value_2
            and integrity)
    except Exception as err:
        error_by_except(s, err)
예제 #20
0
def linked_list_test_19():
    s = "Hago varias operaciones (4 insert uno detras del otro, 1 pop con indice, 1 pop sin indice y un remove, un length y un index)"
    value_1 = "La orden de los factores"
    value_2 = "No altera el producto"
    try:
        test_list = LinkedList()
        many_insert(test_list, value_1, 2)
        many_insert(test_list, value_2, 1)
        many_insert(test_list, value_1, 1)
        test_list.pop()
        test_list.pop(0)
        test_list.remove(value_1)
        has_thrown_exception = False

        def custom_test2():
            if not check_list_integrity(test_list, 1):
                return errors["integrity"]
            return ""

        def custom_test():
            if test_list.prim.v != value_2:
                return errors["assert"]
            return ""

        result = test_runner(custom_test(), index(test_list),
                             length(test_list, 1), custom_test2())
        test.print_test(s, result)
    except Exception as err:
        error_by_except(s, err)
예제 #21
0
def linked_list_test_31():
    s = "Pruebo hacer un append"
    value_1 = "Javascript No.1"
    try:
        test_list = LinkedList()
        test_list.append(value_1)

        def custom_test1():
            return errors["integrity"] if not check_list_integrity(
                test_list, 1) else ""

        def custom_test2():
            return errors["assert"] if not (test_list.prim.v
                                            == value_1) else ""

        test.print_test(s, test_runner(custom_test1(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #22
0
def linked_list_test_42():
    s = "Pruebo hacer un index de un elemento que ya borre utilizando REMOVE"
    value_1 = "Esta?"
    value_2 = "O no esta?"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 4)
        many_append(test_list, value_2, 1)
        many_append(test_list, value_1, 4)
        test_list.remove(value_2)

        def custom_test():
            index = test_list.index(value_2)
            if index is not None:
                return errors["assert"]
            return ""

        test.print_test(s, test_runner(custom_test()))
    except Exception as err:
        error_by_except(s, err)
예제 #23
0
def linked_list_test_18():
    s = "Pruebo hacer remove de un elemento que existe"
    value_1 = "El 8N es la fiesta de medios"
    value_2 = "El 8N es la fiesta de gestion"
    try:
        test_list = LinkedList()
        many_append(test_list, value_1, 10)
        append(test_list, value_2)
        many_append(test_list, value_1, 5)
        test_list.remove(value_2)
        integrity = check_list_integrity(test_list, 15)

        def custom_test():
            if not integrity:
                return errors["integrity"]
            return ""

        test.print_test(s, test_runner(custom_test()))
    except Exception as err:
        error_by_except(s, err)
예제 #24
0
def linked_list_test_3():
    s = "Pruebo insertar elemento"
    value = "Hola"
    try:
        test_list = LinkedList()
        test_list.insert(0, value)
        integrity = check_list_integrity(test_list, 1)

        def custom_test():
            if not integrity:
                return errors["integrity"]
            return ""

        def custom_test2():
            if test_list.prim.v == value and test_list.prim.next is None:
                return ""
            return errors["assert"]

        test.print_test(s, test_runner(custom_test2(), custom_test()))
    except Exception as err:
        error_by_except(s, err)
예제 #25
0
def linked_list_test_4():
    s = "Pruebo insertar 2 elementos uno detras del otro"
    value = "bokita el mas grande"
    try:
        test_list = LinkedList()
        test_list.insert(0, 2)
        test_list.insert(1, value)

        def custom_test():
            if check_list_is_correct(test_list.prim, 2, [2, value]):
                return ""
            return errors["assert"]

        def custom_test2():
            if check_list_integrity(test_list, 2):
                return ""
            return errors["integrity"]

        test.print_test(s, test_runner(custom_test(), custom_test2()))

    except Exception as err:
        error_by_except(s, err)
예제 #26
0
def linked_list_test_41():
    s = "Hago un pop del ultimo elemento de la lista con indice."
    value_1 = "Esto"
    value_2 = "No esta todo ok"
    try:
        test_list = LinkedList()
        correct_list = []
        for i in range(0, 3):
            append(test_list, value_1)
            append(test_list, value_2)
            correct_list.append(value_1)
            correct_list.append(value_2)

        correct_popped = []
        test_popped = []

        for i in range(0, 3):
            correct_popped.append(correct_list.pop(len(correct_list) - 1))
            current = test_list.prim
            index = 0
            while current is not None:
                current = current.next
                index += 1
            test_popped.append(test_list.pop(index - 1))

        def custom_test():
            if correct_popped == test_popped and check_list_is_correct(
                    test_list.prim, value_1, correct_list):
                return ""
            return errors["assert"]

        def custom_test3():
            if check_list_integrity(test_list, 3):
                return ""
            return errors["integrity"]

        test.print_test(s, test_runner(custom_test(), custom_test3()))
    except Exception as err:
        error_by_except(s, err)
예제 #27
0
def linked_list_test_32():
    s = "Pruebo hacer varios append"
    value_1 = "Python No.2"
    value_2 = "Java No.3"
    value_3 = "PHP is shit"
    try:
        test_list = LinkedList()
        test_list.append(value_1)
        test_list.append(value_2)
        test_list.append(value_3)

        def custom_test1():
            return errors["integrity"] if not check_list_integrity(
                test_list, 3) else ""

        def custom_test2():
            return errors["assert"] if not (check_list_is_correct(
                test_list.prim, value_1, [value_1, value_2, value_3])) else ""

        test.print_test(s, test_runner(custom_test1(), custom_test2()))
    except Exception as err:
        error_by_except(s, err)
예제 #28
0
def linked_list_test_29():
    s = "Hago pop default de una lista con elementos intercalados"
    value_1 = "Foo"
    value_2 = "Bar"
    try:
        test_list = LinkedList()
        for i in range(0, 8):
            append(test_list, value_1)
            append(test_list, value_2)
        result = []
        expected_result = [value_2, value_1, value_2]
        for i in range(0, 3):
            result.append(test_list.pop())

        def custom_test1():
            return errors["assert"] if not (result == expected_result) else ""

        def custom_test2():
            return errors["integrity"] if not check_list_integrity(
                test_list, 13) else ""

        test.print_test(s, test_runner(custom_test2(), custom_test1()))
    except Exception as err:
        error_by_except(s, err)
예제 #29
0
def linked_list_test_30():
    s = "Hago pop y append del pop varias veces"
    value_1 = (1, 2, 3)
    value_2 = (4, 5, 6)
    value_3 = (7, 8, 9)
    try:
        test_list = LinkedList()
        for i in range(0, 4):
            test_list.append(value_1)
            test_list.append(value_2)
            test_list.append(value_3)
        for i in range(0, 9):
            temp = test_list.pop()
            test_list.append(temp)

        def custom_test():
            return errors["integrity"] if not check_list_integrity(
                test_list, 12) else ""

        test.print_test(s, test_runner(custom_test()))
    except Exception as err:
        error_by_except(s, err)