GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_IS_OK/main.cpp Lines: 72 72 100.0 %
Date: 2024-12-09 15:30:52 Branches: 230 230 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 <iostream>
9
#include "phoenix_assert.h"
10
#include "phoenix_check.h"
11
12
///Check the phoenix_check
13
/**	@param val : value
14
 * 	@param valSame : same value
15
 * 	@param valDifferent : different value
16
 * 	@return true on success, false otherwise
17
*/
18
template<typename T>
19
20
bool checkPhoenixCheck(T val, T valSame, T valDifferent){
20
20
	bool b(true);
21
20
	b &= phoenix_check("checkPhoenixCheck : OK : ", val, valSame);
22
20
	b &= !phoenix_check("checkPhoenixCheck : FAIL : ", val, valDifferent);
23
20
	return b;
24
}
25
26
///Test the string filename function
27
1
void testIsOk(){
28
1
	std::cout << "testIsOk : OK => " << phoenix_isOk(true) << std::endl;
29
1
	std::cout << "testIsOk : FAIL => " << phoenix_isOk(false) << std::endl;
30
31


1
	phoenix_assert(phoenix_check("testIsOk : OK : ", phoenix_isOk(true), std::string("\033[32mOK\033[0m")));
32


1
	phoenix_assert(phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), std::string("\033[31mFAIL\033[0m")));
33


1
	phoenix_assert(phoenix_check("testIsOk : OK : ", phoenix_isOk(true), "\033[32mOK\033[0m"));
34


1
	phoenix_assert(phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), "\033[31mFAIL\033[0m"));
35

1
	phoenix_assert(checkPhoenixCheck<int>(42, 42, 28));
36

1
	phoenix_assert(checkPhoenixCheck<short>(42, 42, 28));
37

1
	phoenix_assert(checkPhoenixCheck<long>(42, 42, 28));
38

1
	phoenix_assert(checkPhoenixCheck<char>(42, 42, 43));
39

1
	phoenix_assert(checkPhoenixCheck<unsigned int>(42, 42, 28));
40

1
	phoenix_assert(checkPhoenixCheck<unsigned short>(42, 42, 28));
41

1
	phoenix_assert(checkPhoenixCheck<unsigned long>(42, 42, 28));
42

1
	phoenix_assert(checkPhoenixCheck<unsigned char>(42, 42, 43));
43

1
	phoenix_assert(checkPhoenixCheck<float>(42, 42, 28));
44

1
	phoenix_assert(checkPhoenixCheck<double>(42, 42, 28));
45
1
}
46
47
///Check the vector
48
1
void testCheckVector(){
49
2
	std::vector<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
50
1
	vecVal.push_back("1");
51
1
	vecVal.push_back("2");
52
1
	vecVal.push_back("3");
53
54
1
	vecValShort.push_back("1");
55
1
	vecValShort.push_back("2");
56
57
1
	vecValLong.push_back("1");
58
1
	vecValLong.push_back("2");
59
1
	vecValLong.push_back("3");
60
1
	vecValLong.push_back("4");
61
62

1
	phoenix_assert(phoenix_check("Vec equal", vecVal, vecVal));
63

1
	phoenix_assert(!phoenix_check("Vec equal empty left", vecEmpty, vecVal));
64

1
	phoenix_assert(!phoenix_check("Vec equal empty right", vecVal, vecEmpty));
65

1
	phoenix_assert(phoenix_check("Vec empty", vecEmpty, vecEmpty));
66

1
	phoenix_assert(!phoenix_check("Vec equal short left", vecValShort, vecVal));
67

1
	phoenix_assert(!phoenix_check("Vec equal short right", vecVal, vecValShort));
68

1
	phoenix_assert(!phoenix_check("Vec equal long left", vecValLong, vecVal));
69

1
	phoenix_assert(!phoenix_check("Vec equal long right", vecVal, vecValLong));
70
1
}
71
72
///Check the list
73
1
void testCheckList(){
74
2
	std::list<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
75
1
	vecVal.push_back("1");
76
1
	vecVal.push_back("2");
77
1
	vecVal.push_back("3");
78
79
1
	vecValShort.push_back("1");
80
1
	vecValShort.push_back("2");
81
82
1
	vecValLong.push_back("1");
83
1
	vecValLong.push_back("2");
84
1
	vecValLong.push_back("3");
85
1
	vecValLong.push_back("4");
86
87

1
	phoenix_assert(phoenix_check("List equal", vecVal, vecVal));
88

1
	phoenix_assert(!phoenix_check("List equal empty left", vecEmpty, vecVal));
89

1
	phoenix_assert(!phoenix_check("List equal empty right", vecVal, vecEmpty));
90

1
	phoenix_assert(phoenix_check("List empty", vecEmpty, vecEmpty));
91

1
	phoenix_assert(!phoenix_check("List equal short left", vecValShort, vecVal));
92

1
	phoenix_assert(!phoenix_check("List equal short right", vecVal, vecValShort));
93

1
	phoenix_assert(!phoenix_check("List equal long left", vecValLong, vecVal));
94

1
	phoenix_assert(!phoenix_check("List equal long right", vecVal, vecValLong));
95
1
}
96
97
///Check the file content
98
1
void testCheckFileContent(){
99


1
	phoenix_assert(phoenix_check_fileContent("Check file content", "", ""));
100
1
}
101
102
1
int main(int argc, char** argv){
103
1
	testIsOk();
104
1
	testCheckVector();
105
1
	testCheckList();
106
1
	testCheckFileContent();
107
1
	return 0;
108
}
109
110