GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/TESTS/TEST_IS_OK/main.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 72 72 100.0%
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
2/2
✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
20 b &= phoenix_check("checkPhoenixCheck : OK : ", val, valSame);
22
2/2
✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
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
2/2
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
1 std::cout << "testIsOk : OK => " << phoenix_isOk(true) << std::endl;
29
2/2
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
1 std::cout << "testIsOk : FAIL => " << phoenix_isOk(false) << std::endl;
30
31
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
1 phoenix_assert(phoenix_check("testIsOk : OK : ", phoenix_isOk(true), std::string("\033[32mOK\033[0m")));
32
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
1 phoenix_assert(phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), std::string("\033[31mFAIL\033[0m")));
33
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
1 phoenix_assert(phoenix_check("testIsOk : OK : ", phoenix_isOk(true), "\033[32mOK\033[0m"));
34
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
1 phoenix_assert(phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), "\033[31mFAIL\033[0m"));
35
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(checkPhoenixCheck<int>(42, 42, 28));
36
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(checkPhoenixCheck<short>(42, 42, 28));
37
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(checkPhoenixCheck<long>(42, 42, 28));
38
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(checkPhoenixCheck<char>(42, 42, 43));
39
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(checkPhoenixCheck<unsigned int>(42, 42, 28));
40
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(checkPhoenixCheck<unsigned short>(42, 42, 28));
41
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(checkPhoenixCheck<unsigned long>(42, 42, 28));
42
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(checkPhoenixCheck<unsigned char>(42, 42, 43));
43
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(checkPhoenixCheck<float>(42, 42, 28));
44
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(checkPhoenixCheck<double>(42, 42, 28));
45 1 }
46
47 ///Check the vector
48 1 void testCheckVector(){
49 1 std::vector<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
50
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("1");
51
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("2");
52
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("3");
53
54
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValShort.push_back("1");
55
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValShort.push_back("2");
56
57
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("1");
58
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("2");
59
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("3");
60
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("4");
61
62
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_check("Vec equal", vecVal, vecVal));
63
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal empty left", vecEmpty, vecVal));
64
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal empty right", vecVal, vecEmpty));
65
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_check("Vec empty", vecEmpty, vecEmpty));
66
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal short left", vecValShort, vecVal));
67
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal short right", vecVal, vecValShort));
68
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal long left", vecValLong, vecVal));
69
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("Vec equal long right", vecVal, vecValLong));
70 1 }
71
72 ///Check the list
73 1 void testCheckList(){
74 1 std::list<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
75
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("1");
76
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("2");
77
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecVal.push_back("3");
78
79
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValShort.push_back("1");
80
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValShort.push_back("2");
81
82
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("1");
83
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("2");
84
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("3");
85
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 vecValLong.push_back("4");
86
87
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_check("List equal", vecVal, vecVal));
88
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal empty left", vecEmpty, vecVal));
89
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal empty right", vecVal, vecEmpty));
90
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_check("List empty", vecEmpty, vecEmpty));
91
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal short left", vecValShort, vecVal));
92
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal short right", vecVal, vecValShort));
93
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal long left", vecValLong, vecVal));
94
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_check("List equal long right", vecVal, vecValLong));
95 1 }
96
97 ///Check the file content
98 1 void testCheckFileContent(){
99
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
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
111