GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/TESTS/TEST_CONVERT_TO_STRING/main.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 20 20 100.0%
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
1/1
✓ Branch 1 taken 9 times.
18 std::string convertedValue(convertToString(value));
23
1/1
✓ Branch 1 taken 9 times.
36 return phoenix_check(testName, convertedValue, strReference);
24 18 }
25
26 ///Test convert to string
27 1 void testConvertToString(){
28
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<int>("Test value int", 1, "1"));
29
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<unsigned int>("Test value unsigned int", 1, "1"));
30
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<long int>("Test value long int", 1, "1"));
31
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<long unsigned int>("Test value long unsigned int", 1, "1"));
32
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<double>("Test value double", 1.0, "1"));
33
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<double>("Test value double", 1.5, "1.5"));
34
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<float>("Test value float", 1.0f, "1"));
35
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(checkResultConvertToString<float>("Test value float", 1.5f, "1.5"));
36
8/8
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
1 phoenix_assert(checkResultConvertToString<std::string>("Test value string", "1.0f", "1.0f"));
37
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(stringToValue<int>("314") == 314);
38
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
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
48