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_check.h" |
10 |
|
|
|
11 |
|
|
///Check the phoenix_check |
12 |
|
|
/** @param val : value |
13 |
|
|
* @param valSame : same value |
14 |
|
|
* @param valDifferent : different value |
15 |
|
|
* @return true on success, false otherwise |
16 |
|
|
*/ |
17 |
|
|
template<typename T> |
18 |
|
20 |
bool checkPhoenixCheck(T val, T valSame, T valDifferent){ |
19 |
|
20 |
bool b(true); |
20 |
✓✓ |
20 |
b &= phoenix_check("checkPhoenixCheck : OK : ", val, valSame); |
21 |
✓✓ |
20 |
b &= !phoenix_check("checkPhoenixCheck : FAIL : ", val, valDifferent); |
22 |
|
20 |
return b; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
///Test the string filename function |
26 |
|
|
/** @return true on success, false otherwise |
27 |
|
|
*/ |
28 |
|
1 |
bool testIsOk(){ |
29 |
✓✓ |
1 |
std::cout << "testIsOk : OK => " << phoenix_isOk(true) << std::endl; |
30 |
✓✓ |
1 |
std::cout << "testIsOk : FAIL => " << phoenix_isOk(false) << std::endl; |
31 |
|
|
|
32 |
|
1 |
bool b(true); |
33 |
✓✓✓✓
|
1 |
b &= phoenix_check("testIsOk : OK : ", phoenix_isOk(true), std::string("\033[32mOK\033[0m")); |
34 |
✓✓✓✓
|
1 |
b &= phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), std::string("\033[31mFAIL\033[0m")); |
35 |
|
|
|
36 |
✓✓✓✓
|
1 |
b &= phoenix_check("testIsOk : OK : ", phoenix_isOk(true), "\033[32mOK\033[0m"); |
37 |
✓✓✓✓
|
1 |
b &= phoenix_check("testIsOk : FAIL : ", phoenix_isOk(false), "\033[31mFAIL\033[0m"); |
38 |
|
|
|
39 |
|
1 |
b &= checkPhoenixCheck<int>(42, 42, 28); |
40 |
|
1 |
b &= checkPhoenixCheck<short>(42, 42, 28); |
41 |
|
1 |
b &= checkPhoenixCheck<long>(42, 42, 28); |
42 |
|
1 |
b &= checkPhoenixCheck<char>(42, 42, 43); |
43 |
|
|
|
44 |
|
1 |
b &= checkPhoenixCheck<unsigned int>(42, 42, 28); |
45 |
|
1 |
b &= checkPhoenixCheck<unsigned short>(42, 42, 28); |
46 |
|
1 |
b &= checkPhoenixCheck<unsigned long>(42, 42, 28); |
47 |
|
1 |
b &= checkPhoenixCheck<unsigned char>(42, 42, 43); |
48 |
|
|
|
49 |
|
1 |
b &= checkPhoenixCheck<float>(42, 42, 28); |
50 |
|
1 |
b &= checkPhoenixCheck<double>(42, 42, 28); |
51 |
|
|
|
52 |
✓✓ |
1 |
phoenix_functionOk("testIsOk", b); |
53 |
|
1 |
return b; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
///Check the vector |
57 |
|
|
/** @return true on success, false otherwise |
58 |
|
|
*/ |
59 |
|
1 |
bool testCheckVector(){ |
60 |
|
2 |
std::vector<std::string> vecVal, vecValShort, vecValLong, vecEmpty; |
61 |
✓✓ |
1 |
vecVal.push_back("1"); |
62 |
✓✓ |
1 |
vecVal.push_back("2"); |
63 |
✓✓ |
1 |
vecVal.push_back("3"); |
64 |
|
|
|
65 |
✓✓ |
1 |
vecValShort.push_back("1"); |
66 |
✓✓ |
1 |
vecValShort.push_back("2"); |
67 |
|
|
|
68 |
✓✓ |
1 |
vecValLong.push_back("1"); |
69 |
✓✓ |
1 |
vecValLong.push_back("2"); |
70 |
✓✓ |
1 |
vecValLong.push_back("3"); |
71 |
✓✓ |
1 |
vecValLong.push_back("4"); |
72 |
|
|
|
73 |
|
1 |
bool b(true); |
74 |
✓✓ |
1 |
b &= phoenix_check("Vec equal", vecVal, vecVal); |
75 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal empty left", vecEmpty, vecVal); |
76 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal empty right", vecVal, vecEmpty); |
77 |
|
|
|
78 |
✓✓ |
1 |
b &= phoenix_check("Vec empty", vecEmpty, vecEmpty); |
79 |
|
|
|
80 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal short left", vecValShort, vecVal); |
81 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal short right", vecVal, vecValShort); |
82 |
|
|
|
83 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal long left", vecValLong, vecVal); |
84 |
✓✓ |
1 |
b &= !phoenix_check("Vec equal long right", vecVal, vecValLong); |
85 |
|
|
|
86 |
✓✓ |
1 |
phoenix_functionOk("testCheckVector", b); |
87 |
|
2 |
return b; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
///Check the list |
91 |
|
|
/** @return true on success, false otherwise |
92 |
|
|
*/ |
93 |
|
1 |
bool testCheckList(){ |
94 |
|
2 |
std::list<std::string> vecVal, vecValShort, vecValLong, vecEmpty; |
95 |
✓✓ |
1 |
vecVal.push_back("1"); |
96 |
✓✓ |
1 |
vecVal.push_back("2"); |
97 |
✓✓ |
1 |
vecVal.push_back("3"); |
98 |
|
|
|
99 |
✓✓ |
1 |
vecValShort.push_back("1"); |
100 |
✓✓ |
1 |
vecValShort.push_back("2"); |
101 |
|
|
|
102 |
✓✓ |
1 |
vecValLong.push_back("1"); |
103 |
✓✓ |
1 |
vecValLong.push_back("2"); |
104 |
✓✓ |
1 |
vecValLong.push_back("3"); |
105 |
✓✓ |
1 |
vecValLong.push_back("4"); |
106 |
|
|
|
107 |
|
1 |
bool b(true); |
108 |
✓✓ |
1 |
b &= phoenix_check("List equal", vecVal, vecVal); |
109 |
✓✓ |
1 |
b &= !phoenix_check("List equal empty left", vecEmpty, vecVal); |
110 |
✓✓ |
1 |
b &= !phoenix_check("List equal empty right", vecVal, vecEmpty); |
111 |
|
|
|
112 |
✓✓ |
1 |
b &= phoenix_check("List empty", vecEmpty, vecEmpty); |
113 |
|
|
|
114 |
✓✓ |
1 |
b &= !phoenix_check("List equal short left", vecValShort, vecVal); |
115 |
✓✓ |
1 |
b &= !phoenix_check("List equal short right", vecVal, vecValShort); |
116 |
|
|
|
117 |
✓✓ |
1 |
b &= !phoenix_check("List equal long left", vecValLong, vecVal); |
118 |
✓✓ |
1 |
b &= !phoenix_check("List equal long right", vecVal, vecValLong); |
119 |
|
|
|
120 |
✓✓ |
1 |
phoenix_functionOk("testCheckList", b); |
121 |
|
2 |
return b; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
///Check the file content |
125 |
|
|
/** @return true on success, false otherwise |
126 |
|
|
*/ |
127 |
|
1 |
bool testCheckFileContent(){ |
128 |
|
1 |
bool b(true); |
129 |
✓✓✓✓
|
1 |
b &= phoenix_check_fileContent("Check file content", "", ""); |
130 |
✓✓ |
1 |
phoenix_functionOk("testCheckFileContent", b); |
131 |
|
1 |
return b; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
1 |
int main(int argc, char** argv){ |
135 |
|
1 |
bool b(true); |
136 |
|
1 |
b &= testIsOk(); |
137 |
|
1 |
b &= testCheckVector(); |
138 |
|
1 |
b &= testCheckList(); |
139 |
|
1 |
b &= testCheckFileContent(); |
140 |
|
1 |
return b - 1; |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
|