Skip to content

Commit

Permalink
25/11
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
vickygidekel committed Nov 25, 2023
1 parent 3e90585 commit 48c866e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 44 deletions.
6 changes: 3 additions & 3 deletions Proyecto/libreria/archivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "clientes.h"
#include "clases.h"

eCodArchivos leerArchivoClientes(ifstream &archiClientes, sClientes* cliente, u_int *cant) //archivo CSV
eCodArchivos leerArchivoClientes(ifstream &archiClientes, sClientes* cliente, u_int &cant) //archivo CSV
{
sClientes* aux = new sClientes[*cant]; //tamaño
sClientes* aux = new sClientes[cant]; //tamaño
string auxNombre;
string auxApellido;
string auxDNI;
Expand Down Expand Up @@ -51,7 +51,7 @@ eCodArchivos leerArchivoClientes(ifstream &archiClientes, sClientes* cliente, u_
i++;
}
archiClientes.close();
for(u_int i=0; i<*cant; i++)
for(u_int i=0; i<cant; i++)
cliente[i]=aux[i];
delete[] aux;
return eCodArchivos::ExitoOperacion;
Expand Down
2 changes: 1 addition & 1 deletion Proyecto/libreria/archivo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

typedef enum CodArchivos {ErrorLectura=-3, ErrorApertura=-2, ErrorEscritura=-1, ExitoOperacion=1} eCodArchivos;

eCodArchivos leerArchivoClientes(ifstream& archiClientes, sClientes* cliente, u_int *cant);
eCodArchivos leerArchivoClientes(ifstream& archiClientes, sClientes* cliente, u_int &cant);
eCodArchivos escribirArchivoClientes(ofstream& archiClientes, str nombre, str apellido, str email, str telefono,
Fecha fechaNac, int estado, u_int idCliente);
eCodArchivos leerArchivoClases(ifstream& archiClases, Clases* clase);
Expand Down
6 changes: 3 additions & 3 deletions Proyecto/libreria/clientes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int buscarCliente(sClientes* cliente, str dni, u_int &cant)
if(cliente[i].dni==dni)
return cliente[i].idCliente;
}
if(i==cant)
//if(i==cant)
return -1;
}
eEstado Cuota(sClientes* cliente, str dni, u_int &cant)
Expand All @@ -49,7 +49,7 @@ eEstado Cuota(sClientes* cliente, str dni, u_int &cant)
}
}
}
int eliminarCliente(sClientes* cliente, str dni, u_int &cant)
u_int eliminarCliente(sClientes* cliente, str dni, u_int &cant)
{
u_int id=buscarCliente(cliente, dni, cant); //cambiar tamaño
u_int i=0;
Expand Down Expand Up @@ -83,7 +83,7 @@ u_int cantClientes(ifstream &archiClientes)
eAgregar agregarCliente(sClientes* cliente, sClientes nuevoCliente, u_int &cant, u_int cantMaxima)
{
int id = buscarCliente(cliente, nuevoCliente.dni, cant);
u_int nuevoTam = (cant)+30;
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 @@ -38,7 +38,7 @@ const sClientes clienteNulo{"","","","","",{0,0,0},0,0};
sClientes* resizeClientes(sClientes* cliente, u_int &tam, u_int nuevoTam); //tamaño de clientes
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
int eliminarCliente(sClientes* cliente, str dni, u_int &cant); //eliminar 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
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
Expand Down
2 changes: 1 addition & 1 deletion Proyecto/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main()
if(result != eCodArchivos::ExitoOperacion)
cout << "Hubo un error." << endl;

eCodArchivos result2 = leerArchivoClientes(archiClientes, cliente, cant);
eCodArchivos result2 = leerArchivoClientes(archiClientes, cliente, *cant);
if(result2 != eCodArchivos::ExitoOperacion)
cout << "Hubo un error." << endl;

Expand Down
39 changes: 17 additions & 22 deletions Proyecto/testing/test_clases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ Reservas clases(sClientes cliente, Asistencia* asistencia, Clases nombreClase);
{21,6,{2,168999097}}
};
hay un par de errores con el testing del resize de asistencias pero no llegamos a resolverlo
*/
const Inscripcion DefaultInscripcion[3] = {
{5,168999097},
{8,168999097},
{2,168999097}
};

};*/
/*
TEST_CASE("Inscripcion multiple")
{
Asistencia *aux= new Asistencia; //tamaño
aux=nullptr;
Asistencia *aux= new Asistencia[1]; //tamaño
sClientes cliente;
u_int num=1;
u_int cantClientes;
Expand All @@ -39,21 +36,21 @@ TEST_CASE("Inscripcion multiple")
cliente.mail={"[email protected]"};
cliente.nombre={"Martina"};
cliente.telefono={"123-456-786"};
cliente.idCliente=1;
aux->cantInscriptos=1;
aux->CursosInscriptos->idCurso=3;
aux->CursosInscriptos->fechaInscripcion=16112023;
aux->idCliente=1;
curso->horarioClase=5;
curso->idClase=3;
curso->nombreClase={"boxeo"};
clases(cliente, aux, curso, cantClientes, curso->nombreClase, curso->horarioClase);//revisar
clases(cliente, aux, curso, cantClientes, curso->nombreClase, curso->horarioClase);
SECTION("Verificacion de inscripcion"){
Inscripto result = estaInscriptoClases(aux, curso, curso->nombreClase, curso->horarioClase);
REQUIRE(result == 1);
}
SECTION("Superposicion horaria"){
superposicion superp = superposicionHorarios(aux, curso, cliente.idCliente, cantClientes,curso->nombreClase, curso->horarioClase);
REQUIRE(superp == 1);
Expand Down Expand Up @@ -88,7 +85,7 @@ TEST_CASE("Resize")
CHECK(antigua != inscripcion);
}
/*SECTION("Resize asistencia"){
SECTION("Resize asistencia"){
Asistencia* asistencia = new Asistencia[2];
Inscripcion* inscripcion = new Inscripcion[2];
Expand All @@ -102,28 +99,26 @@ TEST_CASE("Resize")
u_int cant;
cant=num;
resizeAsistencia(asistencia, cant , 2 + 3);
asistencia[2] = {"23","1",inscripcion[3]};
asistencia[2] = {"28","2",inscripcion[3]};
asistencia[2] = {23,1,inscripcion};
asistencia[2] = {28,2,inscripcion};
CHECK(vieja != asistencia);
}*/
}
}
}*/
TEST_CASE("Verificar espacio")
{
SECTION("Asistencia"){
int cantmax=40;
u_int num=6;
u_int cant;
cant=num;
u_int cantmax=40;
u_int cant=6;
REQUIRE(!espacioAsistencias(cantmax,cant));
}

SECTION("Inscricion"){
Asistencia* asistencia;
int cantmax=40;
u_int num=2;
u_int cant;
cant=num;
Inscripcion* inscripcion = new Inscripcion[1];
inscripcion[1]={5,168999097};
Asistencia asistencia[1]={23, 1, inscripcion};
u_int cantmax=40;
asistencia->cantInscriptos=6;
REQUIRE(!espacioInscripciones(asistencia,cantmax));
}
}
24 changes: 11 additions & 13 deletions Proyecto/testing/test_clientes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ const sClientes DefaultCliente[3] = {
{"Felipe", "Gonzalez", "44312783", "[email protected]", "987-654-3210", {15, 11, 1992}, 0, 2},
{"Laura", "Fernandez", "32145638", "[email protected]", "316-424-5885", {3, 9, 1995}, 0, 3}
};

/*
TEST_CASE("Agregar cliente")
{
sClientes* cliente= new sClientes;
cliente=nullptr;
u_int cant=NULL;
int cantMaxima=6;
u_int cant=0;
u_int cantMaxima=6;
SECTION("Agregando dos clientes")
{
eAgregar resul;
eAgregar resul2;
resul= agregarCliente(cliente,{"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1}, cant, cantMaxima); //agregar cliente
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); //agregar cliente
eAgregar resul2= agregarCliente(cliente,{"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2}, cant, cantMaxima);
if(resul==1 && resul2==1)
cant=2;
REQUIRE(resul==1); //ambos se agregaron de manera correcta
Expand All @@ -55,7 +53,7 @@ TEST_CASE("Buscar cliente")
SECTION("Buscando el cliente por DNI")
{
int resul = buscarCliente(cliente, "46534213", cant);
REQUIRE(resul == 0);
REQUIRE(resul == 1);
}
}
Expand Down Expand Up @@ -124,26 +122,26 @@ TEST_CASE("Resize cliente")
u_int cant;
cant=num;
resizeClientes(clientes, cant , 3 + 2);
clientes[3] = {"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,1};
clientes[3] = {"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,2};
clientes[3] = {"Valentina","Perez","46534213","valenPrez@gmial", "115-233-5643",{12,3,2006},0,4};
clientes[4] = {"Marcos","Aguilar","45025423","Aguilar115@gmial", "120-465-3289",{6,7,1996},123,5};
CHECK(ViejaDireccion != clientes);
}
}
}*/

TEST_CASE("Estado de la cuota")
{
sClientes* cliente = new sClientes[3];
//eEstado Cuota(sClientes* cliente, str dni, int cant)
str dni1={"46534213"};
str dni1={"46203718"};
str dni2={"45025423"};
u_int num=2;
u_int cant;
cant=num;
SECTION("Comprobando estado de dos clientes")
{
eEstado resul=Cuota(cliente, dni1, cant);
REQUIRE(resul==eEstado::AlDia);
REQUIRE(resul==eEstado::Afavor);
eEstado resul2=Cuota(cliente, dni2, cant);
REQUIRE(resul2==eEstado::Afavor);
}
Expand Down

0 comments on commit 48c866e

Please sign in to comment.