GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: TESTS/TEST_TENSOR_CHECK/main.cpp Lines: 52 52 100.0 %
Date: 2026-03-27 22:08:32 Branches: 46 46 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 "tensor_check.h"
8
9
///Test the PTensor check
10
/**	@return true on successn false otherwise
11
*/
12
1
bool testPTensor(){
13
2
	PTensor<int> tensorA(AllocMode::NONE, 7lu);
14
1
	tensorA.fill(1);
15
2
	PTensor<int> tensorAlignA(AllocMode::ALIGNED, 7lu);
16
1
	tensorAlignA.fill(1);
17
2
	PTensor<int> tensorPaddingA(AllocMode::PADDING, 7lu);
18
1
	tensorPaddingA.fill(1);
19
20
2
	PTensor<int> tensorB(AllocMode::NONE, 5lu);
21
1
	tensorB.fill(1);
22
23
2
	PTensor<int> tensorC(AllocMode::NONE, 4lu, 5lu);
24
1
	tensorC.fill(2);
25
26
1
	PTensor<int> tensorD(AllocMode::NONE, 7lu);
27
1
	tensorB.fill(2);
28
29
1
	bool b(true);
30
1
	b &= checkTensor("Test 1D ok", tensorA, tensorA);
31
1
	b &= checkTensor("Test 2D ok", tensorC, tensorC);
32
1
	b &= !checkTensor("Test not same alloc", tensorA, tensorAlignA);
33
1
	b &= !checkTensor("Test not same padding", tensorAlignA, tensorPaddingA);
34
1
	b &= !checkTensor("Test not same number of dimension", tensorA, tensorC);
35
1
	b &= !checkTensor("Test not same shape", tensorA, tensorB);
36
1
	b &= !checkTensor("Test not same values", tensorA, tensorD);
37
38
1
	std::cout << "testPTensor : b = " << b << std::endl;
39
2
	return b;
40
}
41
42
///Test the PTensor check
43
/**	@return true on successn false otherwise
44
*/
45
1
bool testPTensorEpsilon(){
46
2
	PTensor<float> tensorA(AllocMode::NONE, 7lu);
47
1
	tensorA.fill(1.0f);
48
2
	PTensor<float> tensorAlignA(AllocMode::ALIGNED, 7lu);
49
1
	tensorAlignA.fill(1.0f);
50
2
	PTensor<float> tensorPaddingA(AllocMode::PADDING, 7lu);
51
1
	tensorPaddingA.fill(1.0f);
52
53
2
	PTensor<float> tensorB(AllocMode::NONE, 5lu);
54
1
	tensorB.fill(1.0f);
55
56
2
	PTensor<float> tensorC(AllocMode::NONE, 4lu, 5lu);
57
1
	tensorC.fill(2.0f);
58
59
1
	PTensor<float> tensorD(AllocMode::NONE, 7lu);
60
1
	tensorB.fill(2.0f);
61
62
1
	float epsilon(0.1f);
63
64
1
	bool b(true);
65
1
	b &= checkTensorEpsilon("Test 1D ok", tensorA, tensorA, epsilon);
66
1
	b &= checkTensorEpsilon("Test 2D ok", tensorC, tensorC, epsilon);
67
1
	b &= !checkTensorEpsilon("Test not same alloc", tensorA, tensorAlignA, epsilon);
68
1
	b &= !checkTensorEpsilon("Test not same padding", tensorAlignA, tensorPaddingA, epsilon);
69
1
	b &= !checkTensorEpsilon("Test not same number of dimension", tensorA, tensorC, epsilon);
70
1
	b &= !checkTensorEpsilon("Test not same shape", tensorA, tensorB, epsilon);
71
1
	b &= !checkTensorEpsilon("Test not same values", tensorA, tensorD, epsilon);
72
73
1
	std::cout << "testPTensorEpsilon : b = " << b << std::endl;
74
2
	return b;
75
}
76
77
1
int main(int argc, char** argv){
78
1
	bool b(testPTensor());
79
1
	b &= testPTensorEpsilon();
80
1
	std::cout << "final : b = " << b << std::endl;
81
1
	return b - 1;
82
}
83
84