GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/src/phoenix_check.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 26 26 100.0%
Branches: 31 31 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "convertToString.h"
8 #include "string_filename.h"
9 #include "phoenix_check.h"
10
11 ///Check two string
12 /** @param testName : name of the current test
13 * @param val : std::string to be checked
14 * @param reference : reference std::string
15 * @return true if val == reference, false otherwise
16 */
17 156 bool phoenix_check(const std::string & testName, const std::string & val, const std::string & reference){
18 156 bool b(val == reference);
19
2/2
✓ Branch 5 taken 156 times.
✓ Branch 8 taken 156 times.
156 std::cout << "phoenix_check : " << testName << " => " << phoenix_isOk(b) << std::endl;
20 156 std::cout << "\t val = '"<<val<<"'" << std::endl;
21 156 std::cout << "\treference = '"<<reference<<"'" << std::endl;
22 156 return b;
23 }
24
25 ///Check two vector of string
26 /** @param testName : name of the current test
27 * @param listVal : list of std::string to be checked
28 * @param listRef : list of reference std::string
29 * @return true if val == reference, false otherwise
30 */
31 8 bool phoenix_check(const std::string & testName, const std::vector<std::string> & listVal, const std::vector<std::string> & listRef){
32 8 bool b(true);
33 //On this implementation, two vectors of different sizes are not comparable
34
2/2
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
8 b &= phoenix_check(testName + " size", listVal.size(), listRef.size());
35
6/6
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 8 times.
11 for(size_t i(0lu); i < listVal.size() && b; ++i){
36
5/5
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 15 taken 3 times.
3 b &= phoenix_check(testName + " str("+convertToString(i)+")", listVal[i], listRef[i]);
37 }
38 8 return b;
39 }
40
41 ///Check two list of string
42 /** @param testName : name of the current test
43 * @param listVal : list of std::string to be checked
44 * @param listRef : list of reference std::string
45 * @return true if val == reference, false otherwise
46 */
47 9 bool phoenix_check(const std::string & testName, const std::list<std::string> & listVal, const std::list<std::string> & listRef){
48 9 bool b(true);
49 //On this implementation, two list of different sizes are not comparable
50
2/2
✓ Branch 3 taken 9 times.
✓ Branch 6 taken 9 times.
9 b &= phoenix_check(testName + " size", listVal.size(), listRef.size());
51 9 std::list<std::string>::const_iterator itVal(listVal.begin());
52 9 std::list<std::string>::const_iterator itRef(listRef.begin());
53 9 size_t i(0lu);
54
8/8
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 4 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 9 times.
15 while(itVal != listVal.end() && itRef != listRef.end() && b){
55
5/5
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 12 taken 6 times.
✓ Branch 15 taken 6 times.
6 b &= phoenix_check(testName + " str("+convertToString(i)+")", *itVal, *itRef);
56 6 ++itVal;
57 6 ++itRef;
58 6 ++i;
59 }
60 9 return b;
61 }
62
63 ///Check the content of a file
64 /** @param testName : name of the current test
65 * @param fileName : name of the file to be checked
66 * @param expectedContent : expected content of the file
67 * @return true if the file content is correct, false otherwise
68 */
69 1 bool phoenix_check_fileContent(const std::string & testName, const std::string & fileName, const std::string & expectedContent){
70
1/1
✓ Branch 2 taken 1 times.
1 return phoenix_check(testName, getFileContent(fileName), expectedContent);
71 }
72
73