Skip to content

Commit

Permalink
6/12
Browse files Browse the repository at this point in the history
  • Loading branch information
morenaescher committed Dec 6, 2023
1 parent e841c68 commit 1bc1902
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Proyecto/libreria/clientes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ u_int cantClientes(ifstream &archiClientes)
}else
return -1;
}
eAgregar agregarCliente(sClientes* cliente, sClientes nuevoCliente, u_int &cant, u_int cantMaxima)
eAgregar agregarCliente(sClientes* cliente, sClientes nuevoCliente, u_int &cant, u_int &cantMaxima, u_int nuevoTam)
{
int id = buscarCliente(cliente, nuevoCliente.dni, cant);
u_int nuevoTam = cant+30;
if(!espacio(cantMaxima, cant))
{
cliente = resizeClientes(cliente, cant, nuevoTam);
Expand Down
2 changes: 1 addition & 1 deletion Proyecto/libreria/clientes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sClientes* resizeClientes(sClientes* cliente, u_int &tam, u_int nuevoTam); //tam
int buscarCliente(sClientes* cliente, str dni, u_int &cant); //buscar clientes por dni
eEstado Cuota(sClientes* cliente, str dni, u_int &cant); //verificar el estado del cliente
u_int eliminarCliente(sClientes* cliente, str dni, u_int &cant); //eliminar cliente
eAgregar agregarCliente(sClientes* cliente, sClientes nuevoCliente, u_int &cant, u_int cantMaxima); //agregar cliente
eAgregar agregarCliente(sClientes* cliente, sClientes nuevoCliente, u_int &cant, u_int &cantMaxima, u_int nuevoTam); //agregar cliente
eModificar modificarCliente(sClientes* cliente, sClientes clienteModificado, str dni, u_int &cant); //modificar cliente
bool espacio(u_int cantMaxima, u_int &cant); //verificar el espacio disponible
u_int cantClientes(ifstream &archiClientes); //paso el archivo como parámetro y leo la cantidad de registros
Expand Down
2 changes: 1 addition & 1 deletion Proyecto/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int main()
{
case 1: //agregar cliente
{
eAgregar result1 = agregarCliente(cliente, aux, cant, cantMaxima);
eAgregar result1 = agregarCliente(cliente, aux, cant, cantMaxima, nuevoTam);
if(result1 == -1)
cout << "Hubo un error, porfavor vuelva a intentar." << endl;
else
Expand Down
21 changes: 12 additions & 9 deletions Proyecto/testing/test_clientes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ TEST_CASE("Agregar cliente")
cliente=nullptr;
u_int cant=0;
u_int cantMaxima=6;

u_int nuevoTam=cant+3;
SECTION("Agregando dos clientes")
{
eAgregar resul= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima); //agregar cliente
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima);
eAgregar resul= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima, nuevoTam); //agregar cliente
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima, nuevoTam);
if(resul==1 && resul2==1)
cant=2;
REQUIRE(resul==1); //ambos se agregaron de manera correcta
Expand All @@ -45,9 +45,10 @@ TEST_CASE("Buscar cliente")
u_int cant;
cant=num;
u_int cantMaxima=6;
u_int nuevoTam=cant+3;

eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima);
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima);
eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima, nuevoTam);
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima, nuevoTam);
REQUIRE(resul1==1);
REQUIRE(resul2==1);
SECTION("Buscando el cliente por DNI")
Expand All @@ -67,11 +68,12 @@ TEST_CASE("Eliminar cliente")
u_int cantMaxima=6;
u_int resul;
int busqueda;
u_int nuevoTam=cant+3;

SECTION("Eliminando un cliente")
{
eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima);
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima);
eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima, nuevoTam);
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima, nuevoTam);
CHECK(cant==2);
REQUIRE(resul1==1);
REQUIRE(resul2==1);
Expand All @@ -93,10 +95,11 @@ TEST_CASE("Modificar cliente")
cant=num;
u_int cantMaxima=6;
int pos;
u_int nuevoTam=cant+3;
SECTION("Modificando un cliente")
{
eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima); //agregar cliente
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima);
eAgregar resul1= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima, nuevoTam); //agregar cliente
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima, nuevoTam);
REQUIRE(resul1==1);
REQUIRE(resul2==1);
int id=buscarCliente(cliente, dni, cant);
Expand Down

0 comments on commit 1bc1902

Please sign in to comment.