-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpruebas.py
More file actions
44 lines (35 loc) · 1.21 KB
/
pruebas.py
File metadata and controls
44 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import solucion_hash
import solucion_dosArreglos
from time import time
def probar(funcion):
# casos basicos
assert funcion([1, 2, 3], 5) == True # 2+3=5
assert funcion([1, 2, 3], 7) == False # nada suma 7
assert funcion([], 0) == False # arreglo vacío
print("Test casos basicos pasado")
# valores repetidos
assert funcion([2, 2, 2], 4) == True # 2+2=4
assert funcion([5, 5, 5], 9) == False # nunca da 9
print("Test valores repetidos pasado")
# negativos
assert funcion([-3, 1, 4], 1) == True # -3+4=1
assert funcion([-5, -2, -8], -7) == True # -5+-2=-7
assert funcion([-5, -2, -8], -20) == False
print("Test negativos pasado")
# un elemento
assert funcion([10], 20) == True
assert funcion([1], 1) == False
print("Test un elemento pasado")
# listas grandes
t1 = time()
arreglo = list(range(10000)) # 0...9999
assert funcion(arreglo, 9999 + 9999) == True
assert funcion(arreglo, 20000) == False
t2 = time()
print(f"Test listas grandes pasado en: {t2-t1} segundos")
print("PROBANDO SOLUCION CON DOS ARREGLOS:")
probar(solucion_dosArreglos.f)
print()
print("PROBANDO SOLUCION CON HASH:")
probar(solucion_hash.f)
print()