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 #include "string_function.h"
12 
14 
19 bool checkEraseFirstChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
20  std::string strErase(eraseFirstCharsInStr(strExpr, " \t\n"));
21  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
22 }
23 
25 
30 bool checkEraseLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
31  std::string strErase(eraseLastCharsInStr(strExpr, " \t\n"));
32  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
33 }
34 
36 
41 bool checkEraseFirstLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
42  std::string strErase(eraseFirstLastChars(strExpr, " \t\n"));
43  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
44 }
45 
47 
52 bool checkEraseFirstLastCharsVector(const std::string & testName, const std::string & strExpr, const std::string & strReference){
53  std::vector<std::string> vecStrExpr;
54  vecStrExpr.push_back(strExpr);
55  std::vector<std::string> strErase(eraseFirstLastChars(vecStrExpr, " \t\n"));
56  return phoenix_check(testName + "("+strExpr+")", strErase.front(), strReference);
57 }
58 
61  phoenix_assert(checkEraseFirstChars("Erase first chars 1", "one thing", "one thing"));
62  phoenix_assert(checkEraseFirstChars("Erase first chars 2", " one thing", "one thing"));
63  phoenix_assert(checkEraseFirstChars("Erase first chars 3", "one thing ", "one thing "));
64  phoenix_assert(checkEraseFirstChars("Erase first chars 4", " one thing ", "one thing "));
65 }
66 
69  phoenix_assert(checkEraseLastChars("Erase last chars 1", "one thing", "one thing"));
70  phoenix_assert(checkEraseLastChars("Erase last chars 2", " one thing", " one thing"));
71  phoenix_assert(checkEraseLastChars("Erase last chars 3", "one thing ", "one thing"));
72  phoenix_assert(checkEraseLastChars("Erase last chars 4", " one thing ", " one thing"));
73 }
74 
77  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 1", "one thing", "one thing"));
78  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 2", " one thing", "one thing"));
79  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 3", "one thing ", "one thing"));
80  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 4", " one thing ", "one thing"));
81  phoenix_assert(checkEraseFirstLastCharsVector("Erase first last chars 4", " one thing ", "one thing"));
82 }
83 
84 int main(int argc, char** argv){
88  return 0;
89 }
90 
91 
checkEraseFirstLastChars
bool checkEraseFirstLastChars(const std::string &testName, const std::string &strExpr, const std::string &strReference)
Check the erase first last chars.
Definition: main.cpp:41
testBaseEraseLastChars
void testBaseEraseLastChars()
Test string erase last chars.
Definition: main.cpp:68
testBaseEraseFirstChars
void testBaseEraseFirstChars()
Test string erase first chars.
Definition: main.cpp:60
eraseFirstCharsInStr
std::string eraseFirstCharsInStr(const std::string &str, const std::string &chars)
Erase first char in a string.
Definition: string_function.cpp:77
checkEraseLastChars
bool checkEraseLastChars(const std::string &testName, const std::string &strExpr, const std::string &strReference)
Check the erase last chars.
Definition: main.cpp:30
checkEraseFirstLastCharsVector
bool checkEraseFirstLastCharsVector(const std::string &testName, const std::string &strExpr, const std::string &strReference)
Check the erase first last chars.
Definition: main.cpp:52
checkEraseFirstChars
bool checkEraseFirstChars(const std::string &testName, const std::string &strExpr, const std::string &strReference)
Check the erase first chars.
Definition: main.cpp:19
testBaseEraseFirstLastChars
void testBaseEraseFirstLastChars()
Test string erase first last chars.
Definition: main.cpp:76
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
string_function.h
phoenix_assert
#define phoenix_assert(isOk)
Definition: phoenix_assert.h:19
eraseLastCharsInStr
std::string eraseLastCharsInStr(const std::string &str, const std::string &chars)
Erase first and last char in a string.
Definition: string_function.cpp:97
eraseFirstLastChars
std::string eraseFirstLastChars(const std::string &str, const std::string &chars)
Erase first and last char in a string.
Definition: string_function.cpp:122
phoenix_assert.h
main
int main(int argc, char **argv)
Definition: main.cpp:85
phoenix_check.h