Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Bautista Casals
Labo-Algo2
Commits
46ac1455
Commit
46ac1455
authored
2 years ago
by
Bautista Casals
Browse files
Options
Download
Email Patches
Plain Diff
Add new file
parent
b73cfa53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
practica4.cpp
practica4.cpp
+71
-0
No files found.
practica4.cpp
0 → 100644
View file @
46ac1455
#include "gtest-1.8.1/gtest.h"
#include "../src/Libreta.h"
#include "../src/Truco.h"
#include <map>
#include <cmath>
using
namespace
std
;
// Ejercicio 4
TEST
(
Aritmetica
,
suma
)
{
int
valor_calculado
=
15
+
7
;
int
valor_esperado
=
22
;
EXPECT_EQ
(
valor_calculado
,
valor_esperado
);
}
// Ejercicio 5
TEST
(
Aritmetica
,
potencia
)
{
int
valor_calculado
=
10
^
2
;
int
valor_esperado
=
100
;
EXPECT_EQ
(
valor_calculado
,
valor_esperado
);
}
// Ejercicios 6
TEST
(
Aritmetica
,
potencia_general
)
{
for
(
int
i
=
-
5
;
i
<
6
;
i
++
){
EXPECT_EQ
(
pow
(
i
,
2
),
i
*
i
);
}
}
// Ejercicio 7
TEST
(
Diccionario
,
obtener
){
map
<
int
,
int
>
map
;
map
[
1
]
=
10
;
EXPECT_EQ
(
map
[
1
],
10
);
}
// Ejercicio 8
TEST
(
Diccionario
,
definir
){
map
<
int
,
int
>
map
;
int
x
=
17
;
set
<
int
>
m
;
for
(
pair
<
int
,
int
>
n
:
map
){
m
.
insert
(
n
.
first
);
}
EXPECT_EQ
(
m
.
count
(
x
),
0
);
map
[
x
]
=
34
;
EXPECT_EQ
(
map
[
x
],
34
);
}
// Ejercicio 9
TEST
(
Truco
,
inicio
){
Truco
t
;
EXPECT_EQ
(
t
.
puntaje_j1
(),
0
);
EXPECT_EQ
(
t
.
puntaje_j2
(),
0
);
}
// EJercicio 10
TEST
(
Truco
,
Buenas
){
Truco
t
;
EXPECT_FALSE
(
t
.
buenas
(
t
.
puntaje_j1
()));
for
(
int
i
=
1
;
i
<
16
;
i
++
){
t
.
sumar_punto
(
t
.
puntaje_j1
());
}
EXPECT_FALSE
(
t
.
buenas
(
t
.
puntaje_j1
()));
t
.
sumar_punto
(
t
.
puntaje_j1
());
EXPECT_TRUE
(
t
.
buenas
(
t
.
puntaje_j1
()));
for
(
int
i
=
1
;
i
<
3
;
i
++
){
t
.
sumar_punto
(
t
.
puntaje_j1
());
}
EXPECT_TRUE
(
t
.
buenas
(
t
.
puntaje_j1
()));
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment