-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_manejadorNombreArchivo.cpp
46 lines (44 loc) · 1.37 KB
/
test_manejadorNombreArchivo.cpp
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
/*
* test_manejadorNombreArchivo.cpp
*
* Created on: 05/06/2013
* Author: juan
*/
#include "ManejadorNombreArchivo.h"
#include <vector>
#include <iostream>
#define TESTMANEJADORNOMBREARCHIVO
#ifndef TESTMANEJADORNOMBREARCHIVO
int main(void) {
std::string str1("hola"),str2("esto"),str3("es"),str4("una"),str5("prueba.");
std::string palabras[]={str1,str2,str3,str4,str5};
char nombreArchivo[] = "nombresDeArchivos.dat";
ManejadorNombreArchivo* manejador = new ManejadorNombreArchivo(nombreArchivo);
bool res = true;
for( unsigned int i = 0; i< 5; i++) {
if (i != (unsigned int)manejador->agregar_nombre(palabras[i]))
res = false;
}
for( unsigned int i = 0; i< 5; i++) {
if (palabras[i] != manejador->obtener_nombre(i))
res = false;
}
std::cout << "Prueba escritura y lectura de nombre en el manejador de nombres: ";
if (res) std::cout << "correcto."<< std::endl;
else std::cout << "incorrecto" << std::endl;
res = true;
if(manejador->guardar_nombres()) {
delete (manejador);
manejador = new ManejadorNombreArchivo(nombreArchivo);
manejador -> cargar_nombres();
for( unsigned int i = 0; i< 5; i++) {
if (palabras[i] != manejador->obtener_nombre(i))
res = false;
}
}
std::cout << "Prueba persistencia de nombres en el manejador de nombres: ";
if (res) std::cout << "correcto.";
else std::cout << "incorrecto";
delete (manejador);
}
#endif