GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_PSTRING/main.cpp Lines: 69 69 100.0 %
Date: 2023-10-11 10:52:07 Branches: 125 125 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_check.h"
10
11
#include "PString.h"
12
13
///Check string lower expression
14
/**	@param testName : name of the test
15
 * 	@param strValue : string to be tested
16
 * 	@param strReference : reference string
17
 * 	@return true is both strings are equal, false otherwise
18
*/
19
22
bool checkString(const std::string & testName, const std::string & strValue, const std::string & strReference){
20
22
	return phoenix_check(testName, strValue, strReference);
21
}
22
23
///Test the is lower/upper case
24
/**	@return true on success, false otherwise
25
*/
26
1
bool testPString(){
27
1
	bool b(true);
28
3
	PString baseStr("baseString");
29
1
	b &= checkString("Test constructor", baseStr, "baseString");
30
2
	PString checkEqual;
31
1
	checkEqual = baseStr;
32
1
	b &= checkString("Test equal", checkEqual, "baseString");
33
34
2
	PString copyString(baseStr);
35
1
	b &= checkString("Test copy constructor", copyString, "baseString");
36
2
	PString equalOperatorStr;
37
1
	equalOperatorStr = baseStr;
38
1
	b &= checkString("Test equal operator str", equalOperatorStr, "baseString");
39
40
2
	PString equalOperatorFluxStr;
41
1
	equalOperatorFluxStr = baseStr;
42
1
	b &= checkString("Test << operator str", equalOperatorFluxStr, "baseString");
43
44
1
	baseStr += " end";
45
1
	b &= checkString("Test += string", baseStr, "baseString end");
46
47
2
	PString valDouble;
48
1
	valDouble = 42.0;
49
1
	b &= checkString("Test equal operator double", valDouble, "42");
50
51
2
	PString valFloat;
52
1
	valFloat = 42.0f;
53
1
	b &= checkString("Test equal operator float", valFloat, "42");
54
55
2
	PString valDoubleFlux;
56
1
	valDoubleFlux << 42.0;
57
1
	b &= checkString("Test << operator double", valDoubleFlux, "42");
58
59
2
	PString valFloatFlux;
60
1
	valFloatFlux << 42.0f;
61
1
	b &= checkString("Test << operator float", valFloatFlux, "42");
62
63
1
	valDouble += 3.14;
64
1
	b &= checkString("Test += operator double", valDouble, "423.14");
65
66
1
	valFloat += 3.14f;
67
1
	b &= checkString("Test += operator float", valFloat, "423.14");
68
69
2
	PString resAdd = valDouble + valFloat;
70
1
	b &= checkString("Test + operator PString", resAdd, "423.14423.14");
71
72
2
	PString resAddDouble;
73

1
	resAddDouble = PString("double ") + 3.14;
74
1
	b &= checkString("Test + operator double", resAddDouble, "double 3.14");
75
76
2
	PString resAddFloat;
77

1
	resAddFloat = PString("float ") + 3.14;
78
1
	b &= checkString("Test + operator float", resAddFloat, "float 3.14");
79
80

4
	PString strA("str1"), strB("str2"), resResAB, resFluxAB;
81
1
	resResAB = strA + strB;
82
1
	b &= checkString("Test + operator PString", resResAB, "str1str2");
83
1
	resFluxAB << strA << strB;
84
1
	b &= checkString("Test << operator PString", resFluxAB, "str1str2");
85
86
3
	PString strAddStr("Some string");
87
1
	strAddStr += " other string";
88
1
	b &= checkString("Test += operator std::string", strAddStr, "Some string other string");
89
90
3
	PString strAddFluxStr("Some string");
91
1
	strAddFluxStr << " other string";
92
1
	b &= checkString("Test << operator std::string", strAddFluxStr, "Some string other string");
93
94
1
	PString strFlux;
95
1
	strFlux << strAddFluxStr;
96
1
	b &= checkString("Test << operator PString", strFlux, "Some string other string");
97
98
1
	strFlux += std::string(" and the end");
99
1
	b &= checkString("Test += operator std::string", strFlux, "Some string other string and the end");
100
101
1
	strFlux << std::string(".");
102
1
	b &= checkString("Test += operator std::string", strFlux, "Some string other string and the end.");
103
104
1
	strA << (strFlux << strAddFluxStr);
105
1
	phoenix_functionOk("testPString", b);
106
2
	return b;
107
}
108
109
1
int main(int argc, char** argv){
110
1
	bool b(true);
111
1
	b &= testPString();
112
113
1
	phoenix_functionOk("final", b);
114
1
	return b - 1;
115
}
116
117