-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestes_publicos.plt
More file actions
159 lines (101 loc) · 5.49 KB
/
Copy pathtestes_publicos.plt
File metadata and controls
159 lines (101 loc) · 5.49 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
:- use_module(library(plunit)).
:- encoding(utf8).
:- ['listas_palavras.pl'].
% Test suite for various predicates
% To run the tests:
% ?- run_tests.
:- begin_tests(predicates).
% Parte 1
test(media_1) :- media([1, 2, 4, 6], Media),
assertion(Media =:= 3.25).
test(media_2) :- media([], Media),
assertion(Media =:= 0.00).
test(media_3) :- media([1.2, 1.5, 10, 9.6], Media),
assertion(Media =:= 5.57).
test(mediaNotasPorIdade_1) :- mediaNotasPorIdade(16, 18, Media),
assertion(Media =:= 69.87).
test(mediaNotasPorIdade_2) :- mediaNotasPorIdade(16, 30, Media),
assertion(Media =:= 69.95).
test(freqPorGenero_1) :- freqPorGenero(feminino, Media),
assertion(Media =:= 84.70).
test(alertaSaude_1) :- alertaSaude(6, 3, 5, ListaAlaunos),
assertion(ListaAlaunos == [s1067,s1212,s1348,s1598]).
test(alertaSaude_2) :- alertaSaude(7, 4, 6, ListaAlunos),
assertion(ListaAlunos == [s1033,s1051,s1067,s1070,s1118,s1163,s1164,s1209,s1212,s1262,s1298,s1348,s1376,s1399,s1472,s1518,s1551,s1598]).
test(probEcraNotasAltas_1) :- probEcraNotasAltas(4.3, 80, Probabilidade),
assertion(Probabilidade =:= 0).
test(probEcraNotasAltas_2) :- probEcraNotasAltas(4, 80, Probabilidade),
assertion(Probabilidade =:= 0.21).
test(subtraiValorDeLista_1) :- subtraiValorDeLista([2, 7, 8, 1], 4, Resultado),
assertion(Resultado == [-2,3,4,-3]).
test(somaQuadrados_1) :- somaQuadrados([2, 7, 8, 1], Resultado),
assertion(Resultado =:= 118).
test(produtoEscalar_1) :- produtoEscalar([2, 4, 6], [1, 2, 3], Resultado),
assertion(Resultado =:= 28).
test(correlacao_1) :- correlacao([1, 2, 3], [60, 70, 90], Resultado),
assertion(Resultado =:= 0.98).
test(correlacao_2) :- correlacao([1, 2, 3], [90, 70, 60], Resultado),
assertion(Resultado =:= -0.98).
test(correlacao_3) :- correlacao([1, 10, 6], [60, 100, 90], Resultado),
assertion(Resultado =:= 0.98).
% Parte 2
test(tamanho_1) :- tamanho(fidalgo, T),
assertion(T == 7).
test(tamanho_2) :- tamanho(cão, T),
assertion(T == 3).
test(tamanho_3) :- tamanho("Palhaço", T),
assertion(T == 7).
test(verificaECalcula_1) :- verificaECalcula(palhaço, fidalgo, Lista1, Lista2),
assertion(Lista1 == [p,a,l,h,a,ç,o]),
assertion(Lista2 == [f,i,d,a,l,g,o]).
test(verificaECalcula_2, [fail]) :- verificaECalcula(palhaço, cão, _, _).
test(quantasN_1) :- quantasN(mini, 7, Quantas),
assertion(Quantas == 3).
test(quantasN_2) :- quantasN(mini, 4, Quantas),
assertion(Quantas == 0).
test(quantasC_1) :- quantasC(mini, f, Quantas),
assertion(Quantas == 1).
test(quantasC_2) :- quantasC(pt, f, Quantas),
assertion(Quantas == 47).
test(quantasC_3) :- quantasC(mini, m, Quantas),
assertion(Quantas =:= 2).
test(apagaElemento_1) :- apagaElemento(8, [2, 8, 3, 8, 4], L),
assertion(L == [2,3,8,4]).
test(apagaElemento_2) :- apagaElemento(5, [2, 8, 3, 8, 4], L),
assertion(L == [2,8,3,8,4]).
test(posicoesPalavra_1) :- posicoesPalavra(batata, Posicoes),
assertion(Posicoes == [(a,2),(a,4),(a,6),(b,1),(t,3),(t,5)]).
test(pista1_1, [fail]) :- pista1(lara, lar, _).
test(pista1_2) :- pista1(lara, pera, L),
assertion(L == [0,0,2,2]).
test(pista1_3) :- pista1(ramal, arara, L),
assertion(L == [0,0,0,0,0]).
test(pista1_3) :- pista1(ramal, arara, L),
assertion(L == [0,0,0,0,0]).
test(pista1_4) :- pista1(acelera, batatas, L),
assertion(L == [0,0,0,0,0,0,0]).
test(pista2_1, [fail]) :- pista2(lara, lar, _).
test(pista2_2) :- pista2(lara, pera, L),
assertion(L == [0,0,2,2]).
test(pista2_3) :- pista2(ramal, arara, L),
assertion(L == [1,1,1,1,1]).
test(pista2_4) :- pista2(acelera, batatas, L),
assertion(L = [0,1,0,1,0,1,0]).
test(pista3_1, [fail]) :- pista3(lara, lar, _).
test(pista3_2) :- pista3(lara, pera, L),
assertion(L == [0,0,2,2]).
test(pista3_3) :- pista3(ramal, arara, L),
assertion(L == [1,1,1,0,0]).
test(pista3_4) :- pista3(acelera, batatas, L),
assertion(L == [0,1,0,1,0,0,0]).
test(pista3_5) :- pista3(babaa, aabba, L),
assertion(L == [1,2,2,1,2]).
test(pista3_5) :- pista3(babaa, aabca, L),
assertion(L == [1,2,2,0,2]).
test(maratonaFilmes_1) :- maratonaFilmes([strangeDays, léon, memento, indianaJones, jfk, amadeus, topSecret], [soPode(léon, 1), soPode(amadeus, 5), soPode(jfk, 7), naoSeguido(memento, strangeDays), seguido(amadeus, topSecret), nunca(memento, 2)], Programacao),
assertion(Programacao == [[léon,strangeDays,indianaJones,memento,amadeus,topSecret,jfk]]).
test(maratonaFilmes_2) :- maratonaFilmes([f1, f2, f3, f4, f5],[soPode(f1, 1), seguido(f1, f2), terror(f3), soPode(f4, 7), naoSeguido(f4, f3), nunca(f5, 6)], Programacao),
assertion(Programacao == [[f1,f2,empty,f3,f5,empty,f4],[f1,f2,f3,empty,f5,empty,f4],[f1,f2,f3,f5,empty,empty,f4],[f1,f2,f5,f3,empty,empty,f4]]).
test(maratonaFilmes_3) :- maratonaFilmes([f1, f2, f3, f4, f5], [soPode(f1, 1), seguido(f2, f1)], H),
assertion(H == []).
:- end_tests(predicates).