GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/TESTS/TEST_PROGRESS_BAR/main.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 48 48 100.0%
Branches: 69 69 100.0%

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