GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_CONVERT_TO_STRING/main.cpp Lines: 19 19 100.0 %
Date: 2024-12-09 15:30:52 Branches: 78 78 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
12
#include "convertToString.h"
13
14
///Check string expression
15
/**	@param testName : name of the test
16
 * 	@param value : value to be tested
17
 * 	@param strReference : reference string
18
 * 	@return true is both strings are equal, false otherwise
19
*/
20
template<typename T>
21
18
bool checkResultConvertToString(const std::string & testName, T value, const std::string & strReference){
22
36
	std::string convertedValue(convertToString(value));
23
36
	return phoenix_check(testName, convertedValue, strReference);
24
}
25
26
///Test convert to string
27
1
void testConvertToString(){
28

1
	phoenix_assert(checkResultConvertToString<int>("Test value int", 1, "1"));
29

1
	phoenix_assert(checkResultConvertToString<unsigned int>("Test value unsigned int", 1, "1"));
30

1
	phoenix_assert(checkResultConvertToString<long int>("Test value long int", 1, "1"));
31

1
	phoenix_assert(checkResultConvertToString<long unsigned int>("Test value long unsigned int", 1, "1"));
32

1
	phoenix_assert(checkResultConvertToString<double>("Test value double", 1.0, "1"));
33

1
	phoenix_assert(checkResultConvertToString<double>("Test value double", 1.5, "1.5"));
34

1
	phoenix_assert(checkResultConvertToString<float>("Test value float", 1.0f, "1"));
35

1
	phoenix_assert(checkResultConvertToString<float>("Test value float", 1.5f, "1.5"));
36


1
	phoenix_assert(checkResultConvertToString<std::string>("Test value string", "1.0f", "1.0f"));
37

1
	phoenix_assert(stringToValue<int>("314") == 314);
38

1
	phoenix_assert(stringToValue<std::string>("314") == "314");
39
1
}
40
41
42
1
int main(int argc, char** argv){
43
1
	testConvertToString();
44
1
	return 0;
45
}
46
47