PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
phoenix_check.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "convertToString.h"
8 #include "string_filename.h"
9 #include "phoenix_check.h"
10 
12 
17 bool phoenix_check(const std::string & testName, const std::string & val, const std::string & reference){
18  bool b(val == reference);
19  if(!b){
20  std::cout << "phoenix_check : " << testName << " => " << phoenix_isOk(b) << std::endl;
21  std::cout << "\tval = '"<<val<<"'" << std::endl;
22  std::cout << "\treference = '"<<reference<<"'" << std::endl;
23  }
24  return b;
25 }
26 
28 
33 bool phoenix_check(const std::string & testName, const std::vector<std::string> & listVal, const std::vector<std::string> & listRef){
34  bool b(true);
35  //On this implementation, two vectors of different sizes are not comparable
36  b &= phoenix_check(testName + " size", listVal.size(), listRef.size());
37  for(size_t i(0lu); i < listVal.size() && b; ++i){
38  b &= phoenix_check(testName + " str("+convertToString(i)+")", listVal[i], listRef[i]);
39  }
40  return b;
41 }
42 
44 
49 bool phoenix_check(const std::string & testName, const std::list<std::string> & listVal, const std::list<std::string> & listRef){
50  bool b(true);
51  //On this implementation, two list of different sizes are not comparable
52  b &= phoenix_check(testName + " size", listVal.size(), listRef.size());
53  std::list<std::string>::const_iterator itVal(listVal.begin());
54  std::list<std::string>::const_iterator itRef(listRef.begin());
55  size_t i(0lu);
56  while(itVal != listVal.end() && itRef != listRef.end() && b){
57  b &= phoenix_check(testName + " str("+convertToString(i)+")", *itVal, *itRef);
58  ++itVal;
59  ++itRef;
60  ++i;
61  }
62  return b;
63 }
64 
66 
71 bool phoenix_check_fileContent(const std::string & testName, const std::string & fileName, const std::string & expectedContent){
72  return phoenix_check(testName, getFileContent(fileName), expectedContent);
73 }
74 
convertToString
std::string convertToString(const T &val)
Convert a type into a string.
Definition: convertToString_impl.h:17
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
getFileContent
std::string getFileContent(const std::string &filename)
Get the file content in a string.
Definition: string_filename.cpp:268
string_filename.h
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
convertToString.h
phoenix_isOk
std::string phoenix_isOk(bool b)
Print OK or FAIL depending on the given boolean.
Definition: phoenix_isOk.cpp:14
phoenix_check.h