Example #1
0
def EJ1_1():
    s="Lista vacia, resultado vacio"
    try:
        l = []; good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)
Example #2
0
def EJ1_13():
    s="Lista con clave de string, varios tipos para valores"
    try:
        l = [("A", "A"), ("B", 1), ("C", None), ("D", True)]; good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)
Example #3
0
def EJ1_9():
    s="Lista de 10 tuplas, todas claves iguales"
    try:
        l = [("1", "A"), ("1", "B"), ("1", "C"), ("1", "D"), ("1", "E"), ("1", "F"), ("1", "G"), ("1", "H"), ("1", "I"), ("1", "J")]; good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)
Example #4
0
def EJ1_7():
    s="Lista de 5 tuplas, combinaciones de tuplas con misma clave son 2 2 1"
    try:
        l = [("1", "1"), ("1", "2"), ("3", "3"), ("3", "4"), ("5", "5")]; good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)
Example #5
0
def EJ1_4():
    s="Lista de dos tuplas con misma clave"
    try:
        l = [("HOLA", "CHAU"), ("HOLA", "CHAU2")]; good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)
Example #6
0
def EJ1_15():
    s="Caso aleatorio, 10000 elementos, esta garantizado que va a haber claves duplicadas"
    try:
        l = []; 
        for i in range(10000):
            l.append((random.choice([None, 1, 2, 3, True, False, "", "A", "B"]),i))
        good_ref = list(l); good_res = WD_tuplas_a_diccionario(l); errors = []
        res = tuplas_a_diccionario(l)
        if res != good_res:
            errors.append("RESPUESTA ERRONEA")
        if l != good_ref:
            errors.append("REFERENCIA MODIFICADA")
        test.print_test_motivo(s, errors)
    except Exception as err:
        test.error_by_except(s,err)