GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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 <assert.h> |
||
9 |
#include "parser_yml.h" |
||
10 |
|||
11 |
///Check the value of a DicoValue |
||
12 |
/** @param mapKey : DicoValue to be checked |
||
13 |
* @param expectedValue : expected value |
||
14 |
* @return true if the value matches the expectedValue, false otherwise |
||
15 |
*/ |
||
16 |
2 |
bool checkKeyMapValue(const DicoValue * mapKey, const std::string & expectedValue){ |
|
17 |
✓✓ | 2 |
if(mapKey == NULL){ |
18 |
1 |
std::cout << "checkKeyMapValue : map NULL for expectedValue = '"<<expectedValue<<"'" << std::endl; |
|
19 |
1 |
return expectedValue == ""; |
|
20 |
} |
||
21 |
✓✓✓✓ ✓ |
1 |
std::cout << "checkKeyMapValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getString()<<"', expectedValue = '"<<expectedValue<<"'" << std::endl; |
22 |
1 |
bool b(mapKey->getString() == expectedValue); |
|
23 |
1 |
std::cout << "checkKeyMapValue : b = " << b << std::endl; |
|
24 |
1 |
return b; |
|
25 |
} |
||
26 |
|||
27 |
///Check the value of a DicoValue |
||
28 |
/** @param mapKey : DicoValue to be checked |
||
29 |
* @param vecExpectedValue : vector of expected values |
||
30 |
* @return true if the value matches the expectedValue, false otherwise |
||
31 |
*/ |
||
32 |
2 |
bool checkKeyMapVecValue(const DicoValue * mapKey, const std::vector<std::string> & vecExpectedValue){ |
|
33 |
✓✓ | 2 |
if(mapKey == NULL){ |
34 |
✓✓ | 1 |
std::cout << "checkKeyMapVecValue : map NULL for vecExpectedValue = " << std::endl; |
35 |
✓✓✓ | 1 |
phoenix_print(vecExpectedValue); |
36 |
1 |
return vecExpectedValue.size() == 0lu; |
|
37 |
} |
||
38 |
✓✓✓✓ ✓✓✓✓ |
1 |
std::cout << "checkKeyMapVecValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', vecExpectedValue = " << std::endl; |
39 |
✓✓✓ | 1 |
phoenix_print(vecExpectedValue); |
40 |
1 |
bool b(true); |
|
41 |
✓ | 1 |
const VecDicoValue & vecValue = mapKey->getVecChild(); |
42 |
1 |
b &= vecValue.size() == vecExpectedValue.size(); |
|
43 |
✓✓✓✓ ✓✓✓ |
1 |
std::cout << "checkKeyMapVecValue : vecValue.size() = " << vecValue.size() << ", vecExpectedValue.size() = "<< vecExpectedValue.size() << ", isOk = " << b << std::endl; |
44 |
1 |
VecDicoValue::const_iterator it(vecValue.begin()); |
|
45 |
1 |
std::vector<std::string>::const_iterator itRef(vecExpectedValue.begin()); |
|
46 |
✓✗✓✓ ✓✗✓✓ |
3 |
while(b && it != vecValue.end() && itRef != vecExpectedValue.end()){ |
47 |
✓ | 2 |
b &= it->getValue() == *itRef; |
48 |
✓✓✓✓ ✓✓✓✓ |
2 |
std::cout << "\tvalue = '" << it->getValue() << "', reference = '"<< *itRef << "', isOk = " << b << std::endl; |
49 |
2 |
++it; |
|
50 |
2 |
++itRef; |
|
51 |
} |
||
52 |
✓✓✓ | 1 |
std::cout << "checkKeyMapVecValue : b = " << b << std::endl; |
53 |
1 |
return b; |
|
54 |
} |
||
55 |
|||
56 |
///Call the check value with NULL pointers |
||
57 |
1 |
void testCheckValue(){ |
|
58 |
✓✓ | 1 |
checkKeyMapValue(NULL, ""); |
59 |
2 |
std::vector<std::string> vecNoValue; |
|
60 |
✓ | 1 |
checkKeyMapVecValue(NULL, vecNoValue); |
61 |
1 |
} |
|
62 |
|||
63 |
///Check the YML parser |
||
64 |
1 |
void checkParserYml(){ |
|
65 |
✓ | 2 |
std::string ymlFile(FULL_YML_CONFIG); |
66 |
✓ | 2 |
DicoValue dico; |
67 |
✓✗✓ | 1 |
assert(parser_yml(dico, ymlFile)); |
68 |
✓✓ | 1 |
const DicoValue * mapJob = dico.getMap("job"); |
69 |
✗✓ | 1 |
assert(mapJob != NULL); |
70 |
✓✗ | 1 |
if(mapJob != NULL){ |
71 |
✓✓ | 1 |
const DicoValue * mapJobArgument = mapJob->getMap("job_argument"); |
72 |
✓✓✗✓ |
1 |
assert(checkKeyMapValue(mapJobArgument, "-A aswg -p short")); |
73 |
|||
74 |
✓✓ | 1 |
const DicoValue * mapRmDL1 = mapJob->getMap("rmdl1"); |
75 |
✗✓ | 1 |
assert(mapRmDL1 != NULL); |
76 |
✓✗ | 1 |
if(mapRmDL1 != NULL){ |
77 |
✓✓ | 1 |
const DicoValue * mapDemendencies = mapRmDL1->getMap("depdendencies"); |
78 |
|||
79 |
2 |
std::vector<std::string> vecExpectedValue; |
|
80 |
✓✓ | 1 |
vecExpectedValue.push_back("dl1dl2"); |
81 |
✓✓ | 1 |
vecExpectedValue.push_back("plotdl1"); |
82 |
✓✗✓ | 1 |
assert(checkKeyMapVecValue(mapDemendencies, vecExpectedValue)); |
83 |
} |
||
84 |
} |
||
85 |
1 |
} |
|
86 |
|||
87 |
1 |
int main(int argc, char** argv){ |
|
88 |
1 |
testCheckValue(); |
|
89 |
1 |
checkParserYml(); |
|
90 |
1 |
return 0; |
|
91 |
} |
||
92 |
|||
93 |
Generated by: GCOVR (Version 4.2) |