PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "PString.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

void checkCharToString ()
 Check phoenix_charToString. More...
 
void checkCount ()
 Check count. More...
 
void checkEraseChar ()
 Check erase char. More...
 
bool checkEraseFirstChars (const std::string &testName, const std::string &strExpr, const std::string &strReference)
 Check the erase first chars. More...
 
bool checkEraseFirstLastChars (const PString &testName, const PString &strExpr, const PString &strReference)
 Check the erase first last chars. More...
 
bool checkEraseLastChars (const PString &testName, const PString &strExpr, const PString &strReference)
 Check the erase last chars. More...
 
void checkFind ()
 Check the find method. More...
 
void checkFormat ()
 Check format. More...
 
void checkGetCommonBegining ()
 Check the getCommonBegining. More...
 
void checkIsSameBegining ()
 Check isSameBegining. More...
 
void checkPStringLowerUpper ()
 Test lower/upper to string. More...
 
void checkPStringReplace ()
 Check PString Replace. More...
 
void checkSplitMerge ()
 Check the split and merge. More...
 
bool checkString (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string lower expression. More...
 
void checkValueToStringConvertion ()
 Test value to string and string to value. More...
 
int main (int argc, char **argv)
 
void testEscapeString ()
 Test the phoenix_escapeStr function. More...
 
void testPString ()
 Test the PString. More...
 
void testPStringConversion ()
 Test the PString conversion. More...
 

Function Documentation

◆ checkCharToString()

void checkCharToString ( )

Check phoenix_charToString.

Definition at line 171 of file main.cpp.

171  {
173  phoenix_assert(phoenix_charToString("some text") == "some text");
174 }
PString phoenix_charToString(const char *ch)
Convert a char pointer into a string (event if the char pointer is NULL)
Definition: PString.cpp:14
#define phoenix_assert(isOk)

References phoenix_assert, and phoenix_charToString().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkCount()

void checkCount ( )

Check count.

Definition at line 158 of file main.cpp.

158  {
159  phoenix_assert(PString("").count('o') == 0lu);
160  phoenix_assert(PString("some thing to count").count('o') == 3lu);
161  phoenix_assert(PString("some thing to count").count('w') == 0lu);
162 
163  phoenix_assert(PString("some string with text").count("") == 0lu);
164  phoenix_assert(PString("").count("nothing") == 0lu);
165  phoenix_assert(PString("").count("") == 0lu);
166  phoenix_assert(PString("some string with text").count("with") == 1lu);
167  phoenix_assert(PString("one char and two chars").count("char") == 2lu);
168 }
Extends the std::string.
Definition: PString.h:16

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ checkEraseChar()

void checkEraseChar ( )

Check erase char.

Definition at line 251 of file main.cpp.

251  {
252  phoenix_assert(checkString("Test eraseChar", PString("").eraseChar('o'), ""));
253  phoenix_assert(checkString("Test eraseChar", PString("").eraseChar("o"), ""));
254  phoenix_assert(checkString("Test eraseChar", PString("some string to be used").eraseChar('o'), "sme string t be used"));
255  phoenix_assert(checkString("Test eraseChar", PString("some string to be used").eraseChar("o"), "sme string t be used"));
256  phoenix_assert(checkString("Test eraseChar", PString("some string to be used").eraseChar("oxi"), "sme strng t be used"));
257 
258  phoenix_assert(checkString("Test eraseLastChar", PString("").eraseLastChar("afe"), ""));
259  phoenix_assert(checkString("Test eraseLastChar", PString("").eraseLastChar("afe"), ""));
260 
261  phoenix_assert(checkEraseFirstChars("Erase first chars 1", "one thing", "one thing"));
262  phoenix_assert(checkEraseFirstChars("Erase first chars 2", " one thing", "one thing"));
263  phoenix_assert(checkEraseFirstChars("Erase first chars 3", "one thing ", "one thing "));
264  phoenix_assert(checkEraseFirstChars("Erase first chars 4", " one thing ", "one thing "));
265 
266  phoenix_assert(checkEraseLastChars("Erase last chars 1", "one thing", "one thing"));
267  phoenix_assert(checkEraseLastChars("Erase last chars 2", " one thing", " one thing"));
268  phoenix_assert(checkEraseLastChars("Erase last chars 3", "one thing ", "one thing"));
269  phoenix_assert(checkEraseLastChars("Erase last chars 4", " one thing ", " one thing"));
270 
271  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 1", "one thing", "one thing"));
272  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 2", " one thing", "one thing"));
273  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 3", "one thing ", "one thing"));
274  phoenix_assert(checkEraseFirstLastChars("Erase first last chars 4", " one thing ", "one thing"));
275 
276  PVecString vecIn;
277  vecIn.push_back(" one thing ");
278  PVecString vecOut = eraseFirstLastChar(vecIn, " ");
279  phoenix_assert(vecOut.size() == 1lu);
280  phoenix_assert(vecOut.front() == "one thing");
281 }
void eraseFirstLastChar(PVecString &vecOut, const PVecString &vecStr, const PString &vecChar)
Erase first and last characters of all PString in given vector.
Definition: PString.cpp:52
std::vector< PString > PVecString
Definition: PString.h:96
bool checkString(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:20
bool checkEraseLastChars(const PString &testName, const PString &strExpr, const PString &strReference)
Check the erase last chars.
Definition: main.cpp:231
bool checkEraseFirstChars(const std::string &testName, const std::string &strExpr, const std::string &strReference)
Check the erase first chars.
Definition: main.cpp:219
bool checkEraseFirstLastChars(const PString &testName, const PString &strExpr, const PString &strReference)
Check the erase first last chars.
Definition: main.cpp:243

References checkEraseFirstChars(), checkEraseFirstLastChars(), checkEraseLastChars(), checkString(), eraseFirstLastChar(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkEraseFirstChars()

bool checkEraseFirstChars ( const std::string &  testName,
const std::string &  strExpr,
const std::string &  strReference 
)

Check the erase first chars.

Parameters
testName: name of the test
strExpr: string to be parsed to get a MathExpr
strReference: reference string
Returns
true is both strings are equal, false otherwise

Definition at line 219 of file main.cpp.

219  {
220  PString tmp(strExpr);
221  PString strErase(tmp.eraseFirstChar(" \t\n"));
222  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
223 }
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.

References PString::eraseFirstChar(), and phoenix_check().

Referenced by checkEraseChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkEraseFirstLastChars()

bool checkEraseFirstLastChars ( const PString testName,
const PString strExpr,
const PString strReference 
)

Check the erase first last chars.

Parameters
testName: name of the test
strExpr: string to be parsed to get a MathExpr
strReference: reference string
Returns
true is both strings are equal, false otherwise

Definition at line 243 of file main.cpp.

243  {
244  PString tmp(strExpr);
245  PString strErase(tmp.eraseFirstLastChar(" \t\n"));
246  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
247 }

References PString::eraseFirstLastChar(), and phoenix_check().

Referenced by checkEraseChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkEraseLastChars()

bool checkEraseLastChars ( const PString testName,
const PString strExpr,
const PString strReference 
)

Check the erase last chars.

Parameters
testName: name of the test
strExpr: string to be parsed to get a MathExpr
strReference: reference string
Returns
true is both strings are equal, false otherwise

Definition at line 231 of file main.cpp.

231  {
232  PString tmp(strExpr);
233  PString strErase(tmp.eraseLastChar(" \t\n"));
234  return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
235 }

References PString::eraseLastChar(), and phoenix_check().

Referenced by checkEraseChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFind()

void checkFind ( )

Check the find method.

Definition at line 186 of file main.cpp.

186  {
187  phoenix_assert(!PString("").find('0'));
188  phoenix_assert(!PString("123456").find('0'));
189  phoenix_assert(PString("1230456").find('0'));
190 
191  phoenix_assert(!PString("").find("0"));
192  phoenix_assert(!PString("some char").find(""));
193  phoenix_assert(PString("some char").find("co"));
194  phoenix_assert(!PString("some char").find("zwt"));
195 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ checkFormat()

void checkFormat ( )

Check format.

Definition at line 151 of file main.cpp.

151  {
152  PString str3("Some {} to modify with other {}s");
153  phoenix_assert(checkString("Check format", str3.format("sentence"), "Some sentence to modify with other {}s"));
154  phoenix_assert(checkString("Check format", str3.format("violin"), "Some violin to modify with other {}s"));
155 }

References checkString(), PString::format(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkGetCommonBegining()

void checkGetCommonBegining ( )

Check the getCommonBegining.

Definition at line 177 of file main.cpp.

177  {
178  phoenix_assert(PString("").getCommonBegining("") == "");
179  phoenix_assert(PString("someString").getCommonBegining("") == "");
180  phoenix_assert(PString("").getCommonBegining("someString") == "");
181  phoenix_assert(PString("someString").getCommonBegining("someOtherString") == "some");
182  phoenix_assert(PString("someString").getCommonBegining("AndsomeOtherString") == "");
183 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ checkIsSameBegining()

void checkIsSameBegining ( )

Check isSameBegining.

Definition at line 142 of file main.cpp.

142  {
143  phoenix_assert(PString("").isSameBegining(""));
144  phoenix_assert(!PString("").isSameBegining("d"));
145  phoenix_assert(PString("start").isSameBegining("start"));
146  phoenix_assert(PString("start").isSameBegining("st"));
147  phoenix_assert(!PString("st").isSameBegining("start"));
148 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ checkPStringLowerUpper()

void checkPStringLowerUpper ( )

Test lower/upper to string.

Definition at line 284 of file main.cpp.

284  {
285  phoenix_assert(!PString("").isLowerCase());
286  phoenix_assert(!PString("notOnlyLowerCase").isLowerCase());
287  phoenix_assert(PString("fulllowercase").isLowerCase());
288  phoenix_assert(!PString("").isUpperCase());
289  phoenix_assert(!PString("NOToNLYuPPERcASE").isUpperCase());
290  phoenix_assert(PString("FULLYUPPERCASE").isUpperCase());
291  phoenix_assert(!PString("").isNumber());
292  phoenix_assert(!PString("FULLYUPPERCASE").isNumber());
293  phoenix_assert(PString("12345").isNumber());
294 
295  phoenix_assert(checkString("Test", PString("").toLower(), ""));
296  phoenix_assert(checkString("Test", PString("StRiNg").toLower(), "string"));
297  phoenix_assert(checkString("Test", PString("StRiNg1234").toLower(), "string1234"));
298  phoenix_assert(checkString("Test", PString("ABCDEFGHIJKLMNOPQRSTUVWXYZ").toLower(), "abcdefghijklmnopqrstuvwxyz"));
299  phoenix_assert(checkString("Test", PString("").toUpper(), ""));
300  phoenix_assert(checkString("Test", PString("StRiNg").toUpper(), "STRING"));
301  phoenix_assert(checkString("Test", PString("StRiNg1234").toUpper(), "STRING1234"));
302  phoenix_assert(checkString("Test", PString("abcdefghijklmnopqrstuvwxyz").toUpper(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
303  phoenix_assert(checkString("Test", PString("").firstToLower(), ""));
304  phoenix_assert(checkString("Test", PString("ABC").firstToLower(), "aBC"));
305  phoenix_assert(checkString("Test", PString("aBC").firstToLower(), "aBC"));
306  phoenix_assert(checkString("Test", PString("Vec").firstToLower(), "vec"));
307  phoenix_assert(checkString("Test", PString("").firstToUpper(), ""));
308  phoenix_assert(checkString("Test", PString("ABC").firstToUpper(), "ABC"));
309  phoenix_assert(checkString("Test", PString("Vec").firstToUpper(), "Vec"));
310  phoenix_assert(checkString("Test", PString("aBC").firstToUpper(), "ABC"));
311  phoenix_assert(checkString("Test", PString("vec").firstToUpper(), "Vec"));
312  phoenix_assert(checkString("Test", PString("").toLowerUnderscore(), ""));
313  phoenix_assert(checkString("Test", PString("StringType").toLowerUnderscore(), "stringtype"));
314  phoenix_assert(checkString("Test", PString("String Type").toLowerUnderscore(), "string_type"));
315 }

References checkString(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPStringReplace()

void checkPStringReplace ( )

Check PString Replace.

Definition at line 125 of file main.cpp.

125  {
126  PString str = "Some string to modify";
127  phoenix_assert(checkString("Check replace", str.replace("string", "sentence"), "Some sentence to modify"));
128  phoenix_assert(checkString("Check replace", PString("some string to modify").replace("string", "sentence"), "some sentence to modify"));
129 
130  PString str2("Some string to modify");
131  phoenix_assert(checkString("Check replace", str2.replace("string", "sentence", 0lu), "Some string to modify"));
132  phoenix_assert(checkString("Check replace", str2.replace("string", "sentence", 1lu), "Some sentence to modify"));
133 
134  PString str3("Some string to modify with other strings");
135  phoenix_assert(checkString("Check replace", str3.replace("string", "sentence", 1lu), "Some sentence to modify with other strings"));
136  phoenix_assert(checkString("Check replace", str3.replace("string", "violin", 1lu), "Some violin to modify with other strings"));
137 
138  phoenix_assert(checkString("Check replaceChar", PString("some string\nwith\tchar to replace").replaceChar(" \t\n", "_"), "some_string_with_char_to_replace"));
139 }
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
Definition: PString.cpp:204

References checkString(), phoenix_assert, and PString::replace().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkSplitMerge()

void checkSplitMerge ( )

Check the split and merge.

Definition at line 198 of file main.cpp.

198  {
199  phoenix_assert(PString("").split(' ').size() == 0lu);
200  PVecString vecStr(PString("Some String to split").split(' '));
201  phoenix_assert(vecStr.size() == 4lu);
202  phoenix_assert(PString("").merge(vecStr, " ") == "Some String to split");
203 
204  phoenix_assert(PString("").split("").size() == 0lu);
205  phoenix_assert(PString("Some String").split("").size() == 0lu);
206  phoenix_assert(PString("").split(" ").size() == 0lu);
207 
208  PVecString splitStr(PString("Some String to\tsplit").split(" \t"));
209  phoenix_assert(splitStr.size() == 4lu);
210  phoenix_assert(PString("").merge(splitStr, " ") == "Some String to split");
211 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ checkString()

bool checkString ( const std::string &  testName,
const std::string &  strValue,
const std::string &  strReference 
)

Check string lower expression.

Parameters
testName: name of the test
strValue: string to be tested
strReference: reference string
Returns
true is both strings are equal, false otherwise

Definition at line 20 of file main.cpp.

20  {
21  return phoenix_check(testName, strValue, strReference);
22 }

References phoenix_check().

+ Here is the call graph for this function:

◆ checkValueToStringConvertion()

void checkValueToStringConvertion ( )

Test value to string and string to value.

Definition at line 117 of file main.cpp.

117  {
118  PString str;
119  str.fromValue(3.14);
120  phoenix_assert(checkString("Test fromValue", str, "3.14"));
121  phoenix_assert(3.14 == str.toValue<double>());
122 }
PString & fromValue(const T &other)
Convert a value to a PString.
Definition: PString_impl.h:36
static T toValue(const PString &other)
Convert the given string into a value.
Definition: PString_impl.h:27

References checkString(), PString::fromValue(), phoenix_assert, and PString::toValue().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 334 of file main.cpp.

334  {
335  testPString();
339  checkFormat();
340  checkCount();
343  checkFind();
344  checkSplitMerge();
345  checkEraseChar();
348  return 0;
349 }
void checkEraseChar()
Check erase char.
Definition: main.cpp:251
void checkFormat()
Check format.
Definition: main.cpp:151
void checkSplitMerge()
Check the split and merge.
Definition: main.cpp:198
void checkGetCommonBegining()
Check the getCommonBegining.
Definition: main.cpp:177
void checkIsSameBegining()
Check isSameBegining.
Definition: main.cpp:142
void checkPStringLowerUpper()
Test lower/upper to string.
Definition: main.cpp:284
void checkCount()
Check count.
Definition: main.cpp:158
void checkValueToStringConvertion()
Test value to string and string to value.
Definition: main.cpp:117
void testPString()
Test the PString.
Definition: main.cpp:25
void testEscapeString()
Test the phoenix_escapeStr function.
Definition: main.cpp:318
void checkFind()
Check the find method.
Definition: main.cpp:186
void checkPStringReplace()
Check PString Replace.
Definition: main.cpp:125
void checkCharToString()
Check phoenix_charToString.
Definition: main.cpp:171

References checkCharToString(), checkCount(), checkEraseChar(), checkFind(), checkFormat(), checkGetCommonBegining(), checkIsSameBegining(), checkPStringLowerUpper(), checkPStringReplace(), checkSplitMerge(), checkValueToStringConvertion(), testEscapeString(), and testPString().

+ Here is the call graph for this function:

◆ testEscapeString()

void testEscapeString ( )

Test the phoenix_escapeStr function.

Definition at line 318 of file main.cpp.

318  {
319  phoenix_assert(phoenix_check("PString::escapeStr", PString("some string with escape's \"char\"").escapeStr(" '\"", "\\"), "some\\ string\\ with\\ escape\\'s\\ \\\"char\\\""));
320 }

References phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPString()

void testPString ( )

Test the PString.

Definition at line 25 of file main.cpp.

25  {
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 checkEqualStdString;
33  checkEqualStdString = std::string("baseString");
34  phoenix_assert(checkString("Test equal std::string", checkEqualStdString, "baseString"));
35 
36  PString checkConstructorStdString(std::string("baseString"));
37  phoenix_assert(checkString("Test constructor std::string", checkConstructorStdString, "baseString"));
38 
39  PString copyString(baseStr);
40  phoenix_assert(checkString("Test copy constructor", copyString, "baseString"));
41  PString equalOperatorStr;
42  equalOperatorStr = baseStr;
43  phoenix_assert(checkString("Test equal operator str", equalOperatorStr, "baseString"));
44 
45  PString equalOperatorFluxStr;
46  equalOperatorFluxStr = baseStr;
47  phoenix_assert(checkString("Test << operator str", equalOperatorFluxStr, "baseString"));
48 
49  baseStr += " end";
50  phoenix_assert(checkString("Test += string", baseStr, "baseString end"));
51 
52  PString valDouble;
53  valDouble = 42.0;
54  phoenix_assert(checkString("Test equal operator double", valDouble, "42"));
55 
56  PString valFloat;
57  valFloat = 42.0f;
58  phoenix_assert(checkString("Test equal operator float", valFloat, "42"));
59 
60  PString valDoubleFlux;
61  valDoubleFlux << 42.0;
62  phoenix_assert(checkString("Test << operator double", valDoubleFlux, "42"));
63 
64  PString strAndChar("strin");
65  strAndChar += 'g';
66  phoenix_assert(checkString("Test + operator char", strAndChar, "string"));
67 
68  PString valFloatFlux;
69  valFloatFlux << 42.0f;
70  phoenix_assert(checkString("Test << operator float", valFloatFlux, "42"));
71 
72  valDouble += 3.14;
73  phoenix_assert(checkString("Test += operator double", valDouble, "423.14"));
74 
75  valFloat += 3.14f;
76  phoenix_assert(checkString("Test += operator float", valFloat, "423.14"));
77 
78  PString resAdd = valDouble + valFloat;
79  phoenix_assert(checkString("Test + operator PString", resAdd, "423.14423.14"));
80 
81  PString resAddDouble;
82  resAddDouble = PString("double ") + PString::toString(3.14);
83  phoenix_assert(checkString("Test + operator double", resAddDouble, "double 3.14"));
84 
85  PString resAddFloat;
86  resAddFloat = PString("float ") + PString::toString(3.14);
87  phoenix_assert(checkString("Test + operator float", resAddFloat, "float 3.14"));
88 
89  PString strA("str1"), strB("str2"), resResAB, resFluxAB;
90  resResAB = strA + strB;
91  phoenix_assert(checkString("Test + operator PString", resResAB, "str1str2"));
92  resFluxAB << strA << strB;
93  phoenix_assert(checkString("Test << operator PString", resFluxAB, "str1str2"));
94 
95  PString strAddStr("Some string");
96  strAddStr += " other string";
97  phoenix_assert(checkString("Test += operator std::string", strAddStr, "Some string other string"));
98 
99  PString strAddFluxStr("Some string");
100  strAddFluxStr << " other string";
101  phoenix_assert(checkString("Test << operator std::string", strAddFluxStr, "Some string other string"));
102 
103  PString strFlux;
104  strFlux << strAddFluxStr;
105  phoenix_assert(checkString("Test << operator PString", strFlux, "Some string other string"));
106 
107  strFlux += std::string(" and the end");
108  phoenix_assert(checkString("Test += operator std::string", strFlux, "Some string other string and the end"));
109 
110  strFlux << std::string(".");
111  phoenix_assert(checkString("Test += operator std::string", strFlux, "Some string other string and the end."));
112 
113  strA << (strFlux << strAddFluxStr);
114 }
static PString toString(const T &value)
Convert a value to a PString.
Definition: PString_impl.h:18

References checkString(), phoenix_assert, and PString::toString().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPStringConversion()

void testPStringConversion ( )

Test the PString conversion.

Definition at line 323 of file main.cpp.

323  {
324  phoenix_assert(PString::toValue<int>("314") == 314);
325  phoenix_assert(PString::toValue<std::string>("314") == "314");
326 
327  phoenix_assert(PString::toString(true) == "true");
328  phoenix_assert(PString::toString(false) == "false");
329  phoenix_assert(PString::toValue<bool>("true") == true);
330  phoenix_assert(PString::toValue<bool>("false") == false);
331 
332 }

References phoenix_assert, and PString::toString().

+ Here is the call graph for this function: