PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "string_lower_upper.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

bool checkResultFirstLower (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string lower expression. More...
 
bool checkResultFirstUpper (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string upper expression. More...
 
bool checkResultLower (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string lower expression. More...
 
bool checkResultLowerUnderscore (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string lower expression. More...
 
bool checkResultUpper (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string upper expression. More...
 
int main (int argc, char **argv)
 
bool testCharsType (const std::string &tabChar, bool isNumber, bool isLetter, bool isLowerCase, bool isUpperCase, bool isDot, bool isStar)
 Check char type. More...
 
void testIsListStrNumber ()
 Test the is lower/upper case. More...
 
void testIsLowerUpper ()
 Test the is lower/upper case. More...
 
void testIsType ()
 Test the is lower/upper case. More...
 
void testStringLowerUpper ()
 Test lower/upper to string. More...
 

Function Documentation

◆ checkResultFirstLower()

bool checkResultFirstLower ( 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 42 of file main.cpp.

42  {
43  std::string convertedValue(firstToLower(strValue));
44  return phoenix_check(testName + " firstToLower (" + strValue + ")", convertedValue, strReference);
45 }

References firstToLower(), and phoenix_check().

Referenced by testStringLowerUpper().

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

◆ checkResultFirstUpper()

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

Check string upper 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 53 of file main.cpp.

53  {
54  std::string convertedValue(firstToUpper(strValue));
55  return phoenix_check(testName + " firstToUpper (" + strValue + ")", convertedValue, strReference);
56 }

References firstToUpper(), and phoenix_check().

Referenced by testStringLowerUpper().

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

◆ checkResultLower()

bool checkResultLower ( 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  std::string convertedValue(strToLower(strValue));
22  return phoenix_check(testName + " Lower (" + strValue + ")", convertedValue, strReference);
23 }

References phoenix_check(), and strToLower().

Referenced by testStringLowerUpper().

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

◆ checkResultLowerUnderscore()

bool checkResultLowerUnderscore ( 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 64 of file main.cpp.

64  {
65  std::string convertedValue(strToLowerUnderscore(strValue));
66  return phoenix_check(testName + " strToLowerUnderscore (" + strValue + ")", convertedValue, strReference);
67 }

References phoenix_check(), and strToLowerUnderscore().

Referenced by testStringLowerUpper().

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

◆ checkResultUpper()

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

Check string upper 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 31 of file main.cpp.

31  {
32  std::string convertedValue(strToUpper(strValue));
33  return phoenix_check(testName + " Upper (" + strValue + ")", convertedValue, strReference);
34 }

References phoenix_check(), and strToUpper().

Referenced by testStringLowerUpper().

+ 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 162 of file main.cpp.

162  {
165  testIsType();
167  return 0;
168 }

References testIsListStrNumber(), testIsLowerUpper(), testIsType(), and testStringLowerUpper().

+ Here is the call graph for this function:

◆ testCharsType()

bool testCharsType ( const std::string &  tabChar,
bool  isNumber,
bool  isLetter,
bool  isLowerCase,
bool  isUpperCase,
bool  isDot,
bool  isStar 
)

Check char type.

Parameters
tabChar: table of characters with the same results
isNumber: true if the tabChar is composed of numbers
isLetter: true if the tabChar is composed of letters
isLowerCase: true if the tabChar is composed of lower cases
isUpperCase: true if the tabChar is composed of upper cases
isDot: true if the tabChar is composed of dot
isStar: true if the tabChar is composed of star
Returns
true on success, false otherwise

Definition at line 104 of file main.cpp.

104  {
105  bool b(true);
106  for(size_t i(0lu); i < tabChar.size(); ++i){
107  char ch(tabChar[i]);
108  b &= isCharNumber(ch) == isNumber;
109  b &= isCharLetter(ch) == isLetter;
110  b &= (isCharNumberOrLetter(ch) == (isNumber || isLetter));
111 
112  b &= isCharLowerCase(ch) == isLowerCase;
113  b &= isCharUpperCase(ch) == isUpperCase;
114  b &= isCharNumberOrLetterOrDot(ch) == (isNumber || isLetter || isDot);
115  b &= isCharNumberOrLetterOrStar(ch) == (isNumber || isLetter || isStar);
116  b &= isCharNumberOrStar(ch) == (isNumber || isStar);
117  b &= isCharLetterOrStar(ch) == (isLetter || isStar);
118 
119  }
120  std::cout << "testCharsType ("<<tabChar<<", isNumber = "<<isNumber<<", isLetter = "<<isLetter<<", isLowerCase = "<<isLowerCase<<", isUpperCase = "<<isUpperCase<<", isDot = "<<isDot<<", isStar = "<<isStar<<": ";
121 
122  phoenix_functionOk("testCharsType", b);
123  return b;
124 }

References isCharLetter(), isCharLetterOrStar(), isCharLowerCase(), isCharNumber(), isCharNumberOrLetter(), isCharNumberOrLetterOrDot(), isCharNumberOrLetterOrStar(), isCharNumberOrStar(), isCharUpperCase(), and phoenix_functionOk().

Referenced by testIsType().

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

◆ testIsListStrNumber()

void testIsListStrNumber ( )

Test the is lower/upper case.

Definition at line 151 of file main.cpp.

151  {
152  std::list<std::string> listNb;
154  listNb.push_back("10");
156  listNb.push_back("1");
158  listNb.push_back("Not a number");
160 }

References isListStrNumber(), and phoenix_assert.

Referenced by main().

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

◆ testIsLowerUpper()

void testIsLowerUpper ( )

Test the is lower/upper case.

Definition at line 89 of file main.cpp.

89  {
92 }

References isStrLowerCase(), isStrUpperCase(), and phoenix_assert.

Referenced by main().

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

◆ testIsType()

void testIsType ( )

Test the is lower/upper case.

Definition at line 127 of file main.cpp.

127  {
129  phoenix_assert(!isStrNumber("TEST"));
130  phoenix_assert(!isStrNumber("test"));
131  phoenix_assert(isStrNumber("12346"));
143  phoenix_assert(testCharsType("0123456789", true, false, false, false, false, false));
144  phoenix_assert(testCharsType("abcdefghijklmnopqrstuvwxyz", false, true, true, false, false, false));
145  phoenix_assert(testCharsType("ABCDEFGHIJKLMNOPQRSTUVWXYZ", false, true, false, true, false, false));
146  phoenix_assert(testCharsType(".", false, false, false, false, true, false));
147  phoenix_assert(testCharsType("*", false, false, false, false, false, true));
148 }

References isCharNumberOrDot(), isStrNumber(), isStrNumberDotMinusPlusE(), isStrNumberOrDot(), phoenix_assert, and testCharsType().

Referenced by main().

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

◆ testStringLowerUpper()

void testStringLowerUpper ( )

Test lower/upper to string.

Definition at line 70 of file main.cpp.

70  {
71  phoenix_assert(checkResultLower("Test", "StRiNg", "string"));
72  phoenix_assert(checkResultLower("Test", "StRiNg1234", "string1234"));
73  phoenix_assert(checkResultLower("Test", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"));
74  phoenix_assert(checkResultUpper("Test", "StRiNg", "STRING"));
75  phoenix_assert(checkResultUpper("Test", "StRiNg1234", "STRING1234"));
76  phoenix_assert(checkResultUpper("Test", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
77  phoenix_assert(checkResultFirstLower("Test", "ABC", "aBC"));
78  phoenix_assert(checkResultFirstLower("Test", "aBC", "aBC"));
79  phoenix_assert(checkResultFirstLower("Test", "Vec", "vec"));
80  phoenix_assert(checkResultFirstUpper("Test", "ABC", "ABC"));
81  phoenix_assert(checkResultFirstUpper("Test", "Vec", "Vec"));
82  phoenix_assert(checkResultFirstUpper("Test", "aBC", "ABC"));
83  phoenix_assert(checkResultFirstUpper("Test", "vec", "Vec"));
84  phoenix_assert(checkResultLowerUnderscore("Test", "StringType", "stringtype"));
85  phoenix_assert(checkResultLowerUnderscore("Test", "String Type", "string_type"));
86 }

References checkResultFirstLower(), checkResultFirstUpper(), checkResultLower(), checkResultLowerUnderscore(), checkResultUpper(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
isCharNumberOrLetterOrDot
bool isCharNumberOrLetterOrDot(char ch)
Tels if the character is a letter, number, '.' or '_'.
Definition: string_lower_upper.cpp:114
firstToLower
std::string firstToLower(const std::string &str)
Convert first letter of the std::string in lower case.
Definition: string_lower_upper.cpp:262
isStrUpperCase
bool isStrUpperCase(const std::string &str)
Say if the given std::string is in uppercase.
Definition: string_lower_upper.cpp:162
strToLower
std::string strToLower(const std::string &str)
Convert std::string in lower case.
Definition: string_lower_upper.cpp:190
isCharLetter
bool isCharLetter(char ch)
Tels if the character is a letter or '_'.
Definition: string_lower_upper.cpp:98
phoenix_functionOk
void phoenix_functionOk(const std::string &functionName, bool b)
Print the check function return.
Definition: phoenix_isOk.cpp:23
firstToUpper
std::string firstToUpper(const std::string &str)
Convert first letter of the std::string in upper case.
Definition: string_lower_upper.cpp:248
testCharsType
bool testCharsType(const std::string &tabChar, bool isNumber, bool isLetter, bool isLowerCase, bool isUpperCase, bool isDot, bool isStar)
Check char type.
Definition: main.cpp:104
strToLowerUnderscore
std::string strToLowerUnderscore(const std::string &str)
Convert std::string in lower case and space in '_'.
Definition: string_lower_upper.cpp:228
checkResultLowerUnderscore
bool checkResultLowerUnderscore(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:64
checkResultLower
bool checkResultLower(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:20
isStrLowerCase
bool isStrLowerCase(const std::string &str)
Say if the given std::string is in lowercase.
Definition: string_lower_upper.cpp:176
testIsListStrNumber
void testIsListStrNumber()
Test the is lower/upper case.
Definition: main.cpp:151
testIsLowerUpper
void testIsLowerUpper()
Test the is lower/upper case.
Definition: main.cpp:89
checkResultUpper
bool checkResultUpper(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string upper expression.
Definition: main.cpp:31
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
isCharNumberOrLetterOrStar
bool isCharNumberOrLetterOrStar(char ch)
Tels if the character is letter, number, star or '_'.
Definition: string_lower_upper.cpp:138
isCharUpperCase
bool isCharUpperCase(char ch)
Tels if the character is upper case letter.
Definition: string_lower_upper.cpp:146
testStringLowerUpper
void testStringLowerUpper()
Test lower/upper to string.
Definition: main.cpp:70
isCharLowerCase
bool isCharLowerCase(char ch)
Tels if the character is lower case letter.
Definition: string_lower_upper.cpp:154
isCharNumberOrStar
bool isCharNumberOrStar(char ch)
Tels if the character is number or star.
Definition: string_lower_upper.cpp:122
isStrNumber
bool isStrNumber(const std::string &str)
Tels if std::string contains figures.
Definition: string_lower_upper.cpp:22
isCharNumberOrDot
bool isCharNumberOrDot(char ch)
Tels if the character is a number or a '.'.
Definition: string_lower_upper.cpp:52
isCharLetterOrStar
bool isCharLetterOrStar(char ch)
Tels if the character is letter, star or '_'.
Definition: string_lower_upper.cpp:130
isListStrNumber
bool isListStrNumber(const std::list< std::string > &listStr)
Say if the list of std::string contains a number.
Definition: string_lower_upper.cpp:37
phoenix_assert
#define phoenix_assert(isOk)
Definition: phoenix_assert.h:19
checkResultFirstUpper
bool checkResultFirstUpper(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string upper expression.
Definition: main.cpp:53
isCharNumberOrLetter
bool isCharNumberOrLetter(char ch)
Tels if the character is letter, figure or '_'.
Definition: string_lower_upper.cpp:106
testIsType
void testIsType()
Test the is lower/upper case.
Definition: main.cpp:127
isCharNumber
bool isCharNumber(char ch)
Tels if the character is a number or not.
Definition: string_lower_upper.cpp:14
strToUpper
std::string strToUpper(const std::string &str)
Convert std::string in upper case.
Definition: string_lower_upper.cpp:209
checkResultFirstLower
bool checkResultFirstLower(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:42
isStrNumberOrDot
bool isStrNumberOrDot(const std::string &str)
Tels if std::string contains figures or dots.
Definition: string_lower_upper.cpp:68
isStrNumberDotMinusPlusE
bool isStrNumberDotMinusPlusE(const std::string &str)
Tels if std::string std::string contains figures, '.', -, +, e or E.
Definition: string_lower_upper.cpp:83