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 
12 #include "PString.h"
13 
15 
20 bool checkString(const std::string & testName, const std::string & strValue, const std::string & strReference){
21  return phoenix_check(testName, strValue, strReference);
22 }
23 
25 void testPString(){
26  PString baseStr("baseString");
27  phoenix_assert(checkString("Test constructor", baseStr, "baseString"));
28  PString checkEqual;
29  checkEqual = baseStr;
30  phoenix_assert(checkString("Test equal", checkEqual, "baseString"));
31 
32  PString copyString(baseStr);
33  phoenix_assert(checkString("Test copy constructor", copyString, "baseString"));
34  PString equalOperatorStr;
35  equalOperatorStr = baseStr;
36  phoenix_assert(checkString("Test equal operator str", equalOperatorStr, "baseString"));
37 
38  PString equalOperatorFluxStr;
39  equalOperatorFluxStr = baseStr;
40  phoenix_assert(checkString("Test << operator str", equalOperatorFluxStr, "baseString"));
41 
42  baseStr += " end";
43  phoenix_assert(checkString("Test += string", baseStr, "baseString end"));
44 
45  PString valDouble;
46  valDouble = 42.0;
47  phoenix_assert(checkString("Test equal operator double", valDouble, "42"));
48 
49  PString valFloat;
50  valFloat = 42.0f;
51  phoenix_assert(checkString("Test equal operator float", valFloat, "42"));
52 
53  PString valDoubleFlux;
54  valDoubleFlux << 42.0;
55  phoenix_assert(checkString("Test << operator double", valDoubleFlux, "42"));
56 
57  PString valFloatFlux;
58  valFloatFlux << 42.0f;
59  phoenix_assert(checkString("Test << operator float", valFloatFlux, "42"));
60 
61  valDouble += 3.14;
62  phoenix_assert(checkString("Test += operator double", valDouble, "423.14"));
63 
64  valFloat += 3.14f;
65  phoenix_assert(checkString("Test += operator float", valFloat, "423.14"));
66 
67  PString resAdd = valDouble + valFloat;
68  phoenix_assert(checkString("Test + operator PString", resAdd, "423.14423.14"));
69 
70  PString resAddDouble;
71  resAddDouble = PString("double ") + 3.14;
72  phoenix_assert(checkString("Test + operator double", resAddDouble, "double 3.14"));
73 
74  PString resAddFloat;
75  resAddFloat = PString("float ") + 3.14;
76  phoenix_assert(checkString("Test + operator float", resAddFloat, "float 3.14"));
77 
78  PString strA("str1"), strB("str2"), resResAB, resFluxAB;
79  resResAB = strA + strB;
80  phoenix_assert(checkString("Test + operator PString", resResAB, "str1str2"));
81  resFluxAB << strA << strB;
82  phoenix_assert(checkString("Test << operator PString", resFluxAB, "str1str2"));
83 
84  PString strAddStr("Some string");
85  strAddStr += " other string";
86  phoenix_assert(checkString("Test += operator std::string", strAddStr, "Some string other string"));
87 
88  PString strAddFluxStr("Some string");
89  strAddFluxStr << " other string";
90  phoenix_assert(checkString("Test << operator std::string", strAddFluxStr, "Some string other string"));
91 
92  PString strFlux;
93  strFlux << strAddFluxStr;
94  phoenix_assert(checkString("Test << operator PString", strFlux, "Some string other string"));
95 
96  strFlux += std::string(" and the end");
97  phoenix_assert(checkString("Test += operator std::string", strFlux, "Some string other string and the end"));
98 
99  strFlux << std::string(".");
100  phoenix_assert(checkString("Test += operator std::string", strFlux, "Some string other string and the end."));
101 
102  strA << (strFlux << strAddFluxStr);
103 }
104 
105 int main(int argc, char** argv){
106  testPString();
107  return 0;
108 }
109 
110 
PString.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
PString
Extends the std::string.
Definition: PString.h:17
phoenix_assert
#define phoenix_assert(isOk)
Definition: phoenix_assert.h:19
testPString
void testPString()
Test the is lower/upper case.
Definition: main.cpp:25
phoenix_assert.h
checkString
bool checkString(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:21
main
int main(int argc, char **argv)
Definition: main.cpp:85
phoenix_check.h