int pruebaCompresion3(){ unsigned buffer1[TAM_BUF2]; unsigned buffer2[TAM_BUF2]; unsigned *buffer=buffer1; Compresor descompresor(buffer,TAM_BUF2); string descomprimido; /*********************************************************/ /* COMPRIMIENDO */ /*********************************************************/ Compresor compresor(buffer,TAM_BUF2); compresor.comprimirPrimeros((unsigned char*)Terminos::obtenerTermino(0).c_str(),Terminos::obtenerTermino(0).size()); for(int i=1;i<296;i++){ if(!compresor.agregar((unsigned char*)Terminos::obtenerTermino(i).c_str(),Terminos::obtenerTermino(i).size())){ compresor.cerrar(); /*********************************************************/ /* DESCOMPRIMIENDO */ /*********************************************************/ descomprimido.clear(); descompresor.descomprimir(buffer,descomprimido,TAM_BUF2); cout<<descomprimido<<endl; buffer=buffer2; compresor.setContinuacionCompresion(buffer,TAM_BUF2); /*********************************************************/ compresor.comprimirPrimeros((unsigned char*)Terminos::obtenerTermino(i).c_str(),Terminos::obtenerTermino(i).size()); } } compresor.cerrar(); descomprimido.clear(); descompresor.descomprimir(buffer,descomprimido,TAM_BUF2); cout<<descomprimido<<endl; return 0; }
int pruebaCompresion5(){ //AAAAAABBBBBBPPPPPPDSAZXCVBNN� //12345678901234567890123456789012345678901234567890 //AAAAAABBBBBBPPPPPPDSAZXCVBNMqweeeeeeeeetttttttttty //123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 #define CANT_AGREGAR 2 #define CANT_UNSIGNED 30 #define NUMERO_ITERACIONES 70 unsigned char str[]="AAAAAABBBBBBPPPPPPDSAZXCBNMqweeeeeeeeettttttttttuiopasdfghjklzxcvbnm12345678901234567890123456789012345678901234567890"; unsigned array[CANT_UNSIGNED]; Compresor compresor(array,CANT_UNSIGNED); Compresor descompresor(array,CANT_UNSIGNED); string descomprimido; descompresor.setCaracteres(100); for(int i=0;i<NUMERO_ITERACIONES;i++){ compresor.reiniciarBuffer(); compresor.comprimirPrimeros(str,25); compresor.agregar(str+25,25); compresor.agregar(str+2*25,25); compresor.agregar(str+3*25,25); compresor.cerrar(); descomprimido.clear(); descompresor.reiniciarBuffer(); descompresor.descomprimir(array,descomprimido,CANT_UNSIGNED); cout<<str<<endl; cout<<descomprimido<<endl; } return 0; }
int pruebacompresion1(){ unsigned buffer[TAM_BUF1]; //1234567890123456789012345678901234512345678901234567890123456789012345 unsigned char str[MAX_CANT_CHAR+1]="Base class for standard exceptions. All objects thrown by components of the standard library are derived from this class."; /*unsigned char str[MAX_CANT_CHAR+1]="Base class for standard exceptions. All objects thrown by components of the standard library are derived from this class. Ella esta sentadita en el limbo diciendome donde no hay que ir. Hoy la luna me invita a seguir. Determinadas cosas con la que nos sentimos identificados y nos distinguen de otros que no.";*/ /*********************************************************/ /* COMPRIMIENDO */ /*********************************************************/ Compresor compresor(buffer,TAM_BUF1); //compresor.setSalida(&cout); compresor.comprimirPrimeros(str,MAX_CANT_CHAR); compresor.cerrar(); /*********************************************************/ /* DESCOMPRIMIENDO */ /*********************************************************/ Compresor descompresor(buffer,TAM_BUF1); string descomprimido; descompresor.descomprimir(buffer,descomprimido,TAM_BUF1); /*Mostrando resultados*/ cout<<str<<endl; cout<<descomprimido<<endl; return 0; }
int main(int argc, char **argv) { compresor(argv[1]); descompresor(argv[1]); return 0; }
int pruebacompresion2(){ unsigned primer_buffer_comprimido[TAM_BUF1]; unsigned segundo_buffer_comprimido[TAM_BUF2]; //1234567890123456789012345678901234512345678901234567890123456789012345 string fuente_de_caracteres="Base class for standard exceptions. All objects thrown by components of the standard library are derived from this classa"; /*********************************************************/ /* COMPRIMIENDO */ /*********************************************************/ Compresor compresor(primer_buffer_comprimido,TAM_BUF1); /*USANDO EL PRIMER BUFFER*/ compresor.comprimirPrimeros((unsigned char*)fuente_de_caracteres.c_str(),MIN_CANT_CHAR); /*intenta agregar mas de los q pueden entrar*/ compresor.agregar((unsigned char*)fuente_de_caracteres.c_str(),MIN_CANT_CHAR*3); /*intena agregar una cantidad menor*/ compresor.agregar((unsigned char*)fuente_de_caracteres.c_str()+MIN_CANT_CHAR,MIN_CANT_CHAR); /*termina de usar el buffer*/ compresor.cerrar(); /*USANDO EL SEGUNDO BUFFER*/ /*setea el segundo buffer para escribir*/ compresor.setContinuacionCompresion(segundo_buffer_comprimido,TAM_BUF2); /*escribo los primero bits en el nuevo buffer*/ compresor.comprimirPrimeros((unsigned char*)fuente_de_caracteres.c_str()+2*MIN_CANT_CHAR,MIN_CANT_CHAR); /*agrego el resto de los caracteres*/ compresor.agregar((unsigned char*)fuente_de_caracteres.c_str()+3*MIN_CANT_CHAR,fuente_de_caracteres.size()-3*MIN_CANT_CHAR); /*ternimo de usar el segundo buffer*/ compresor.cerrar(); /*********************************************************/ /* DESCOMPRIMIENDO */ /*********************************************************/ Compresor descompresor(primer_buffer_comprimido,TAM_BUF1); string caracteres_descomprimidos; /*Descomprimo los caracteres del primer buffer y muestro*/ descompresor.descomprimir(primer_buffer_comprimido,caracteres_descomprimidos,TAM_BUF1); cout<<fuente_de_caracteres<<"!"<<endl; cout<<caracteres_descomprimidos; /*Descomprimo los caracteres del siguiente buffer y muestro*/ caracteres_descomprimidos.clear();//borrar los anteriores descompresor.setExtremos();//reiniciar descompresor.descomprimir(segundo_buffer_comprimido,caracteres_descomprimidos,TAM_BUF2); cout<<caracteres_descomprimidos<<"!"<<endl; return 0; }