GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_ERASE_FIRST_LAST_CHARS/main.cpp Lines: 32 32 100.0 %
Date: 2024-09-10 03:06:26 Branches: 114 114 100.0 %

Line Branch Exec Source
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
13
///Check the erase first chars
14
/**	@param testName : name of the test
15
 * 	@param strExpr : string to be parsed to get a MathExpr
16
 * 	@param strReference : reference string
17
 * 	@return true is both strings are equal, false otherwise
18
*/
19
4
bool checkEraseFirstChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
20
8
	std::string strErase(eraseFirstCharsInStr(strExpr, " \t\n"));
21

8
	return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
22
}
23
24
///Check the erase last chars
25
/**	@param testName : name of the test
26
 * 	@param strExpr : string to be parsed to get a MathExpr
27
 * 	@param strReference : reference string
28
 * 	@return true is both strings are equal, false otherwise
29
*/
30
4
bool checkEraseLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
31
8
	std::string strErase(eraseLastCharsInStr(strExpr, " \t\n"));
32

8
	return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
33
}
34
35
///Check the erase first last chars
36
/**	@param testName : name of the test
37
 * 	@param strExpr : string to be parsed to get a MathExpr
38
 * 	@param strReference : reference string
39
 * 	@return true is both strings are equal, false otherwise
40
*/
41
4
bool checkEraseFirstLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){
42
8
	std::string strErase(eraseFirstLastChars(strExpr, " \t\n"));
43

8
	return phoenix_check(testName + "("+strExpr+")", strErase, strReference);
44
}
45
46
///Test string erase first chars
47
1
void testBaseEraseFirstChars(){
48


1
	phoenix_assert(checkEraseFirstChars("Erase first chars 1", "one thing", "one thing"));
49


1
	phoenix_assert(checkEraseFirstChars("Erase first chars 2", "   one thing", "one thing"));
50


1
	phoenix_assert(checkEraseFirstChars("Erase first chars 3", "one thing   ", "one thing   "));
51


1
	phoenix_assert(checkEraseFirstChars("Erase first chars 4", "  one thing  ", "one thing  "));
52
1
}
53
54
///Test string erase last chars
55
1
void testBaseEraseLastChars(){
56


1
	phoenix_assert(checkEraseLastChars("Erase last chars 1", "one thing", "one thing"));
57


1
	phoenix_assert(checkEraseLastChars("Erase last chars 2", "   one thing", "   one thing"));
58


1
	phoenix_assert(checkEraseLastChars("Erase last chars 3", "one thing   ", "one thing"));
59


1
	phoenix_assert(checkEraseLastChars("Erase last chars 4", "  one thing  ", "  one thing"));
60
1
}
61
62
///Test string erase first last chars
63
1
void testBaseEraseFirstLastChars(){
64


1
	phoenix_assert(checkEraseFirstLastChars("Erase first last chars 1", "one thing", "one thing"));
65


1
	phoenix_assert(checkEraseFirstLastChars("Erase first last chars 2", "   one thing", "one thing"));
66


1
	phoenix_assert(checkEraseFirstLastChars("Erase first last chars 3", "one thing   ", "one thing"));
67


1
	phoenix_assert(checkEraseFirstLastChars("Erase first last chars 4", "  one thing  ", "one thing"));
68
1
}
69
70
1
int main(int argc, char** argv){
71
1
	testBaseEraseFirstChars();
72
1
	testBaseEraseLastChars();
73
1
	testBaseEraseFirstLastChars();
74
1
	return 0;
75
}
76
77