GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: TESTS/TEST_PHISTOGRAM/main.cpp Lines: 61 61 100.0 %
Date: 2026-03-26 21:03:40 Branches: 53 53 100.0 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#include "PHistogram/PHistogram.h"
8
9
///Test the graph conversion to dot
10
/**	@return true on success, false otherwise
11
*/
12
1
bool testPHistogram(){
13
1
	bool b(true);
14
15
✓
2
	PHistogram<float> hist(-1.0f, 1.0f, 10lu);
16
17
✓
1
	hist.reset();
18
1
	hist.normalize();
19
✓✓
1001
	for(size_t i(0lu); i < 1000lu; ++i){
20
1000
		hist.addValue((((float)(i*27lu%19)) - 9.0)/2.0f);
21
	}
22
✓✓✓✓
✓✓✓✓
✓✓✓
1
	std::cout << "testPHistogram : min = " << hist.getMin() << ", max = " << hist.getMax() << ", range = " << hist.getRange() << ", nbValueUnderMin = " << hist.getUnderXMin() << ", nbValueUpperMax = " << hist.getOverXMax() << std::endl;
23
✓✓
1
	std::cout << hist << std::endl;
24
25
✓
2
	PHistogram<float> hist2(hist);
26
✓✓
1
	std::cout << hist2 << std::endl;
27
1
	hist2.checkLogValue(0.001f);
28
29
✓
2
	PHistogram<float> hist3;
30
✓
1
	hist3 = hist;
31
1
	hist3.normalize();
32
✓✓
1
	std::cout << hist3 << std::endl;
33
34
✓
2
	PHistogram<float> hist4;
35
1
	hist4.setRange(-1.0f, 1.0f);
36
✓
1
	hist4.resize(20lu);
37
✓✓
201
	for(size_t i(0lu); i < 200lu; ++i){
38
200
		hist4.addValue((((float)(i*27lu%19)) - 9.0)/5.0f);
39
	}
40
✓✓
1
	std::cout << hist4 << std::endl;
41
42
✓
2
	PHistogram<float> emptyHist;
43
✓✓
1
	std::cout << emptyHist << std::endl;
44
1
	emptyHist.normalize();
45
46
✓
1
	PHistogram<float> singleValueHist(1lu);
47
✓✓
1
	std::cout << singleValueHist << std::endl;
48
1
	emptyHist.normalize();
49
50
2
	return b;
51
}
52
53
///Test the graph conversion to dot
54
/**	@return true on success, false otherwise
55
*/
56
1
bool testPHistogram2(){
57
1
	bool b(true);
58
59
✓
2
	PHistogram<float> hist(-1.0f, 1.0f, 10lu);
60
1
	float tabValue[] = {1.0f,4.0f,6.0f,3.0f,6.0f,6.0f,7.0f,4.0f,3.0f,7.0f,5.0f,3.0f,5.0f,6.0f};
61
62
1
	hist.addValue(NULL, 0lu);
63
1
	hist.addValue(NULL, 42lu);
64
✓
1
	hist.setValueRange(NULL, 42lu);
65
✓
1
	hist.setValueRange(tabValue, 14lu);
66
67
1
	hist.addValue(tabValue, 14lu);
68
69
✓
1
	hist.setValueRange(tabValue, 0lu);
70
1
	hist.addValue(tabValue, 0lu);
71
72
✓✓
1
	std::cout << hist << std::endl;
73
74
✓
2
	PHistogram<float> hist4(10lu);
75
1
	hist4.setRange(-1.0f, 1.0f);
76
✓
1
	hist4.resize(20lu);
77
✓✓
201
	for(size_t i(0lu); i < 200lu; ++i){
78
200
		hist4.addAmplitude((((float)(i*27lu%19)) - 9.0)/5.0f, -1.0f);
79
	}
80
✓✓
1
	std::cout << hist4 << std::endl;
81
1
	hist4.checkLogValue(0.001f);
82
✓
1
	hist4.resize(0lu);
83
84
✓
1
	PHistogram<float> emptyHist;
85
✓✓
1
	std::cout << emptyHist << std::endl;
86
87
1
	emptyHist.addValue(42.0f);
88
1
	emptyHist.addAmplitude(3.0f, 4.0f);
89
✓
1
	emptyHist.setValueRange(tabValue, 14lu);
90
1
	emptyHist.addValue(tabValue, 14lu);
91
1
	emptyHist.checkLogValue(0.001f);
92
93
2
	return b;
94
}
95
96
1
int main(int argc, char** argv){
97
1
	bool b(testPHistogram());
98
1
	b &= testPHistogram2();
99
1
	return b - 1;
100
}
101
102