PhoenixMock
1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp
Go to the documentation of this file.
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
13
18
template
<
typename
T>
19
bool
checkPhoenixCheck
(T val, T valSame, T valDifferent){
20
bool
b(
true
);
21
b &=
phoenix_check
(
"checkPhoenixCheck : OK : "
, val, valSame);
22
b &= !
phoenix_check
(
"checkPhoenixCheck : FAIL : "
, val, valDifferent);
23
return
b;
24
}
25
27
void
testIsOk
(){
28
std::cout <<
"testIsOk : OK => "
<<
phoenix_isOk
(
true
) << std::endl;
29
std::cout <<
"testIsOk : FAIL => "
<<
phoenix_isOk
(
false
) << std::endl;
30
31
phoenix_assert
(
phoenix_check
(
"testIsOk : OK : "
,
phoenix_isOk
(
true
), std::string(
"\033[32mOK\033[0m"
)));
32
phoenix_assert
(
phoenix_check
(
"testIsOk : FAIL : "
,
phoenix_isOk
(
false
), std::string(
"\033[31mFAIL\033[0m"
)));
33
phoenix_assert
(
phoenix_check
(
"testIsOk : OK : "
,
phoenix_isOk
(
true
),
"\033[32mOK\033[0m"
));
34
phoenix_assert
(
phoenix_check
(
"testIsOk : FAIL : "
,
phoenix_isOk
(
false
),
"\033[31mFAIL\033[0m"
));
35
phoenix_assert
(checkPhoenixCheck<int>(42, 42, 28));
36
phoenix_assert
(checkPhoenixCheck<short>(42, 42, 28));
37
phoenix_assert
(checkPhoenixCheck<long>(42, 42, 28));
38
phoenix_assert
(checkPhoenixCheck<char>(42, 42, 43));
39
phoenix_assert
(checkPhoenixCheck<unsigned int>(42, 42, 28));
40
phoenix_assert
(checkPhoenixCheck<unsigned short>(42, 42, 28));
41
phoenix_assert
(checkPhoenixCheck<unsigned long>(42, 42, 28));
42
phoenix_assert
(checkPhoenixCheck<unsigned char>(42, 42, 43));
43
phoenix_assert
(checkPhoenixCheck<float>(42, 42, 28));
44
phoenix_assert
(checkPhoenixCheck<double>(42, 42, 28));
45
}
46
48
void
testCheckVector
(){
49
std::vector<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
50
vecVal.push_back(
"1"
);
51
vecVal.push_back(
"2"
);
52
vecVal.push_back(
"3"
);
53
54
vecValShort.push_back(
"1"
);
55
vecValShort.push_back(
"2"
);
56
57
vecValLong.push_back(
"1"
);
58
vecValLong.push_back(
"2"
);
59
vecValLong.push_back(
"3"
);
60
vecValLong.push_back(
"4"
);
61
62
phoenix_assert
(
phoenix_check
(
"Vec equal"
, vecVal, vecVal));
63
phoenix_assert
(!
phoenix_check
(
"Vec equal empty left"
, vecEmpty, vecVal));
64
phoenix_assert
(!
phoenix_check
(
"Vec equal empty right"
, vecVal, vecEmpty));
65
phoenix_assert
(
phoenix_check
(
"Vec empty"
, vecEmpty, vecEmpty));
66
phoenix_assert
(!
phoenix_check
(
"Vec equal short left"
, vecValShort, vecVal));
67
phoenix_assert
(!
phoenix_check
(
"Vec equal short right"
, vecVal, vecValShort));
68
phoenix_assert
(!
phoenix_check
(
"Vec equal long left"
, vecValLong, vecVal));
69
phoenix_assert
(!
phoenix_check
(
"Vec equal long right"
, vecVal, vecValLong));
70
}
71
73
void
testCheckList
(){
74
std::list<std::string> vecVal, vecValShort, vecValLong, vecEmpty;
75
vecVal.push_back(
"1"
);
76
vecVal.push_back(
"2"
);
77
vecVal.push_back(
"3"
);
78
79
vecValShort.push_back(
"1"
);
80
vecValShort.push_back(
"2"
);
81
82
vecValLong.push_back(
"1"
);
83
vecValLong.push_back(
"2"
);
84
vecValLong.push_back(
"3"
);
85
vecValLong.push_back(
"4"
);
86
87
phoenix_assert
(
phoenix_check
(
"List equal"
, vecVal, vecVal));
88
phoenix_assert
(!
phoenix_check
(
"List equal empty left"
, vecEmpty, vecVal));
89
phoenix_assert
(!
phoenix_check
(
"List equal empty right"
, vecVal, vecEmpty));
90
phoenix_assert
(
phoenix_check
(
"List empty"
, vecEmpty, vecEmpty));
91
phoenix_assert
(!
phoenix_check
(
"List equal short left"
, vecValShort, vecVal));
92
phoenix_assert
(!
phoenix_check
(
"List equal short right"
, vecVal, vecValShort));
93
phoenix_assert
(!
phoenix_check
(
"List equal long left"
, vecValLong, vecVal));
94
phoenix_assert
(!
phoenix_check
(
"List equal long right"
, vecVal, vecValLong));
95
}
96
98
void
testCheckFileContent
(){
99
phoenix_assert
(
phoenix_check_fileContent
(
"Check file content"
,
""
,
""
));
100
}
101
102
int
main
(
int
argc,
char
** argv){
103
testIsOk
();
104
testCheckVector
();
105
testCheckList
();
106
testCheckFileContent
();
107
return
0;
108
}
109
110
checkPhoenixCheck
bool checkPhoenixCheck(T val, T valSame, T valDifferent)
Check the phoenix_check.
Definition:
main.cpp:19
testIsOk
void testIsOk()
Test the string filename function.
Definition:
main.cpp:27
testCheckFileContent
void testCheckFileContent()
Check the file content.
Definition:
main.cpp:98
phoenix_check_fileContent
bool phoenix_check_fileContent(const std::string &testName, const std::string &fileName, const std::string &expectedContent)
Check the content of a file.
Definition:
phoenix_check.cpp:71
testCheckList
void testCheckList()
Check the list.
Definition:
main.cpp:73
testCheckVector
void testCheckVector()
Check the vector.
Definition:
main.cpp:48
phoenix_check
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.
Definition:
phoenix_check.cpp:17
phoenix_assert
#define phoenix_assert(isOk)
Definition:
phoenix_assert.h:19
phoenix_isOk
std::string phoenix_isOk(bool b)
Print OK or FAIL depending on the given boolean.
Definition:
phoenix_isOk.cpp:14
phoenix_assert.h
main
int main(int argc, char **argv)
Definition:
main.cpp:85
phoenix_check.h
tmp_project
StringUtils
TESTS
TEST_IS_OK
main.cpp
Generated on Mon Dec 9 2024 15:33:41 for PhoenixMock by
1.8.17