GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_CONVERT_TO_STRING/main.cpp Lines: 21 21 100.0 %
Date: 2023-10-11 10:52:07 Branches: 34 34 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 "convertToString.h"
12
13
///Check string expression
14
/**	@param testName : name of the test
15
 * 	@param value : value to be tested
16
 * 	@param strReference : reference string
17
 * 	@return true is both strings are equal, false otherwise
18
*/
19
template<typename T>
20
18
bool checkResultConvertToString(const std::string & testName, T value, const std::string & strReference){
21
36
	std::string convertedValue(convertToString(value));
22
36
	return phoenix_check(testName, convertedValue, strReference);
23
}
24
25
///Test convert to string
26
/**	@return true on success, false otherwise
27
*/
28
1
bool testConvertToString(){
29
1
	bool b(true);
30
1
	b &= checkResultConvertToString<int>("Test value int", 1, "1");
31
1
	b &= checkResultConvertToString<unsigned int>("Test value unsigned int", 1, "1");
32
1
	b &= checkResultConvertToString<long int>("Test value long int", 1, "1");
33
1
	b &= checkResultConvertToString<long unsigned int>("Test value long unsigned int", 1, "1");
34
1
	b &= checkResultConvertToString<double>("Test value double", 1.0, "1");
35
1
	b &= checkResultConvertToString<double>("Test value double", 1.5, "1.5");
36
1
	b &= checkResultConvertToString<float>("Test value float", 1.0f, "1");
37
1
	b &= checkResultConvertToString<float>("Test value float", 1.5f, "1.5");
38

1
	b &= checkResultConvertToString<std::string>("Test value string", "1.0f", "1.0f");
39
40
1
	b &= stringToValue<int>("314") == 314;
41
1
	b &= stringToValue<std::string>("314") == "314";
42
43
1
	return b;
44
}
45
46
47
1
int main(int argc, char** argv){
48
1
	bool b(true);
49
1
	b &= testConvertToString();
50
51
1
	return b - 1;
52
}
53
54