Gitlab is now running v13.10.2 - More info -> here <-

Commit 27912a06 authored by Pierre Aubert's avatar Pierre Aubert

Add progress test

parent a9475c7e
Pipeline #99884 passed with stages
in 1 minute and 45 seconds
......@@ -26,6 +26,18 @@ bool testProgressBar(){
}
progress.finish();
ProgressBarr progress2(progress), progress3;
progress3 = progress2;
std::cout << "testProgressBar : max = " << progress3.getMax() << ", size = " << progress3.getSize() << std::endl;
std::cout << "chPlein = '" << progress3.getChPlein() << "', chMiddle = '" << progress3.getChMiddle() << "', chEnd = '" << progress3.getChEnd() << "'" << std::endl;
progress3.setMax(42);
progress3.setSize(100);
progress3.setChPlein('=');
progress3.setChMiddle('>');
progress3.setChEnd(' ');
return true;
}
......@@ -44,6 +56,14 @@ bool testProgressTime(){
}
progress.finish();
ProgressTime progress2(progress), progress3;
progress3 = progress2;
progress3.setNbSteps(42);
progress3.setChPlein('=');
progress3.setChMiddle('>');
progress3.setChEnd(' ');
return true;
}
......
......@@ -25,6 +25,7 @@ ProgressBarr::ProgressBarr(size_t max, size_t size, char chPlein, char chMiddle,
/** @param progressBarr : barre de progression à copier
*/
ProgressBarr::ProgressBarr(const ProgressBarr & progressBarr){
p_buffer = NULL;
copy(progressBarr);
}
......@@ -146,7 +147,7 @@ ProgressBarr & ProgressBarr::operator = (const ProgressBarr & progressBarr){
@param chEnd : charactère de remplissage de la barre vide
*/
void ProgressBarr::init(size_t max,size_t size, char chPlein, char chMiddle, char chEnd){
p_buffer = new char[size + 1];
p_buffer = new char[size + 1lu];
p_size = size;
p_max = max;
p_chPlein = chPlein;
......@@ -159,6 +160,9 @@ void ProgressBarr::init(size_t max,size_t size, char chPlein, char chMiddle, cha
/** @param progressBarr : barre de chargement à copier
*/
void ProgressBarr::copy(const ProgressBarr & progressBarr){
if(p_buffer != NULL){
delete [] p_buffer;
}
p_buffer = new char[progressBarr.p_size + 1]; //on pense au caractère \0
p_size = progressBarr.p_size;
p_max = progressBarr.p_max;
......
......@@ -32,6 +32,7 @@ ProgressTime::ProgressTime(size_t nbSteps, char chPlein, char chMiddle, char chE
/** @param other : ProgressTime à copier
*/
ProgressTime::ProgressTime(const ProgressTime & other){
p_buffer = NULL;
copyProgressTime(other);
}
......@@ -122,6 +123,10 @@ ProgressTime & ProgressTime::operator = (const ProgressTime & other){
/** @param other : ProgressTime à copier
*/
void ProgressTime::copyProgressTime(const ProgressTime & other){
if(p_buffer != NULL){
delete [] p_buffer;
}
p_buffer = new char[other.p_sizeBarr + 1]; //on pense au caractère \0
p_startTime = other.p_startTime;
p_tempsRestant = other.p_tempsRestant;
p_nbSteps = other.p_nbSteps;
......@@ -136,6 +141,8 @@ void ProgressTime::copyProgressTime(const ProgressTime & other){
p_chPlein = other.p_chPlein;
p_chMiddle = other.p_chMiddle;
p_chEnd = other.p_chEnd;
p_buffer[p_sizeBarr] = '\0';
}
///fonction d'initialisation de ProgressTime
......@@ -151,8 +158,8 @@ void ProgressTime::initialisationProgressTime(size_t nbSteps, char chPlein, char
p_chEnd = chEnd;
start();
p_consoleWidth = getNbColTerminal();
p_sizeBarr = (3*p_consoleWidth)/4; //on prend 3/4 de la taille de la console
p_buffer = new char[p_sizeBarr + 1];
p_sizeBarr = (3u*p_consoleWidth)/4u; //on prend 3/4 de la taille de la console
p_buffer = new char[p_sizeBarr + 1u];
}
///affiche la barre de chargement
......@@ -168,13 +175,14 @@ void ProgressTime::feelbuffer(unsigned int taille){
for(unsigned int i(taille + 1); i <= p_sizeBarr; ++i){
p_buffer[i] = p_chEnd;
}
p_buffer[p_sizeBarr + 1] = '\0';
p_buffer[p_sizeBarr] = '\0';
}
///fonction qui efface la barre de chargement
void ProgressTime::clear(){
for(unsigned int i(0); i <= p_sizeBarr; ++i){
for(unsigned int i(0); i < p_sizeBarr; ++i){
p_buffer[i] = '\r';
}
p_buffer[p_sizeBarr] = '\0';
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment