1 |
|
|
|
2 |
|
|
/*************************************** |
3 |
|
|
Auteur : Pierre Aubert |
4 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
5 |
|
|
Licence : CeCILL-C |
6 |
|
|
****************************************/ |
7 |
|
|
|
8 |
|
|
#include <unistd.h> |
9 |
|
|
|
10 |
|
|
#include <iostream> |
11 |
|
|
|
12 |
|
|
#include "ProgressBarr.h" |
13 |
|
|
#include "ProgressTime.h" |
14 |
|
|
|
15 |
|
|
///Test the ProgressBarr |
16 |
|
|
/** @return true on success, false otherwise |
17 |
|
|
*/ |
18 |
|
1 |
bool testProgressBar(){ |
19 |
|
1 |
size_t nbValue(1000); |
20 |
✓ |
2 |
ProgressBarr progress(nbValue); |
21 |
|
|
|
22 |
✓✓ |
1001 |
for(size_t i(0lu); i < nbValue; ++i){ |
23 |
✓ |
1000 |
progress.progress(i); |
24 |
|
|
|
25 |
✓ |
1000 |
usleep(2000); |
26 |
|
|
} |
27 |
✓ |
1 |
progress.finish(); |
28 |
|
|
|
29 |
✓✓ |
2 |
ProgressBarr progress2(progress), progress3; |
30 |
✓ |
1 |
progress3 = progress2; |
31 |
|
|
|
32 |
✓✓✓✓ ✓✓✓ |
1 |
std::cout << "testProgressBar : max = " << progress3.getMax() << ", size = " << progress3.getSize() << std::endl; |
33 |
✓✓✓✓ ✓✓✓✓ ✓✓✓ |
1 |
std::cout << "chPlein = '" << progress3.getChPlein() << "', chMiddle = '" << progress3.getChMiddle() << "', chEnd = '" << progress3.getChEnd() << "'" << std::endl; |
34 |
|
|
|
35 |
✓ |
1 |
progress3.setMax(42); |
36 |
✓ |
1 |
progress3.setSize(100); |
37 |
✓ |
1 |
progress3.setChPlein('='); |
38 |
✓ |
1 |
progress3.setChMiddle('>'); |
39 |
✓ |
1 |
progress3.setChEnd(' '); |
40 |
|
|
|
41 |
✓ |
2 |
ProgressBarr progress4; |
42 |
✓ |
1 |
progress3 = progress4; |
43 |
✓ |
1 |
progress3.progress(500); |
44 |
✓ |
1 |
progress3.progress(400); |
45 |
|
|
|
46 |
✓ |
1 |
ProgressBarr progress5; |
47 |
✓✓✓✓
|
1 |
std::cout << "testProgressBar : progress5.getMax() = " << progress5.getMax() << std::endl; |
48 |
|
|
|
49 |
|
2 |
return true; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
///Test the ProgressTime |
53 |
|
|
/** @return true on success, false otherwise |
54 |
|
|
*/ |
55 |
|
1 |
bool testProgressTime(){ |
56 |
|
1 |
size_t nbValue(1000); |
57 |
✓ |
2 |
ProgressTime progress(nbValue); |
58 |
|
|
|
59 |
✓ |
1 |
progress.start(); |
60 |
✓✓ |
1001 |
for(size_t i(0lu); i < nbValue; ++i){ |
61 |
✓ |
1000 |
progress.print(); |
62 |
|
|
|
63 |
✓ |
1000 |
usleep(4000); |
64 |
|
|
} |
65 |
✓ |
1 |
progress.finish(); |
66 |
|
|
|
67 |
✓✓ |
2 |
ProgressTime progress2(progress), progress3; |
68 |
✓ |
1 |
progress3 = progress2; |
69 |
|
|
|
70 |
✓ |
1 |
progress3.setNbSteps(42); |
71 |
✓ |
1 |
progress3.setChPlein('='); |
72 |
✓ |
1 |
progress3.setChMiddle('>'); |
73 |
✓ |
1 |
progress3.setChEnd(' '); |
74 |
|
|
|
75 |
✓ |
1 |
ProgressTime progress4(42); |
76 |
✓ |
1 |
progress3 = progress4; |
77 |
✓ |
1 |
progress3.print(); |
78 |
✓ |
1 |
progress3.finish(); |
79 |
|
|
|
80 |
|
2 |
return true; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
1 |
int main(int argc, char** argv){ |
84 |
|
1 |
bool b(true); |
85 |
|
1 |
b &= testProgressBar(); |
86 |
|
1 |
b &= testProgressTime(); |
87 |
|
|
|
88 |
|
1 |
return b - 1; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
|