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/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→9) taken 1 times.
|
2 | if(mapKey == NULL){ |
18 | 1 | std::cout << "checkKeyMapValue : map NULL for expectedValue = '"<<expectedValue<<"'" << std::endl; | |
19 | 1 | return expectedValue == ""; | |
20 | } | ||
21 |
6/6✓ Branch 0 (13→14) taken 1 times.
✓ Branch 2 (14→15) taken 1 times.
✓ Branch 4 (15→16) taken 1 times.
✓ Branch 6 (16→17) taken 1 times.
✓ Branch 8 (17→18) taken 1 times.
✓ Branch 10 (18→19) taken 1 times.
|
1 | std::cout << "checkKeyMapValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getString()<<"', expectedValue = '"<<expectedValue<<"'" << std::endl; |
22 |
1/1✓ Branch 0 (20→21) taken 1 times.
|
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/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→7) taken 1 times.
|
2 | if(mapKey == NULL){ |
34 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | std::cout << "checkKeyMapVecValue : map NULL for vecExpectedValue = " << std::endl; |
35 | // phoenix_print(vecExpectedValue); | ||
36 | 1 | return vecExpectedValue.size() == 0lu; | |
37 | } | ||
38 |
8/8✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
✓ Branch 6 (10→11) taken 1 times.
✓ Branch 8 (11→12) taken 1 times.
✓ Branch 10 (12→13) taken 1 times.
✓ Branch 12 (13→14) taken 1 times.
✓ Branch 14 (14→15) taken 1 times.
|
1 | std::cout << "checkKeyMapVecValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', vecExpectedValue = " << std::endl; |
39 | // phoenix_print(vecExpectedValue); | ||
40 | 1 | bool b(true); | |
41 |
1/1✓ Branch 0 (15→16) taken 1 times.
|
1 | const VecDicoValue & vecValue = mapKey->getVecChild(); |
42 | 1 | b &= vecValue.size() == vecExpectedValue.size(); | |
43 |
7/7✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (20→21) taken 1 times.
✓ Branch 4 (21→22) taken 1 times.
✓ Branch 6 (23→24) taken 1 times.
✓ Branch 8 (24→25) taken 1 times.
✓ Branch 10 (25→26) taken 1 times.
✓ Branch 12 (26→27) taken 1 times.
|
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 |
6/8✓ Branch 0 (53→54) taken 3 times.
✗ Branch 1 (53→71) not taken.
✓ Branch 2 (61→62) taken 2 times.
✓ Branch 3 (61→71) taken 1 times.
✓ Branch 4 (69→70) taken 2 times.
✗ Branch 5 (69→71) not taken.
✓ Branch 6 (72→30) taken 2 times.
✓ Branch 7 (72→73) taken 1 times.
|
8 | while(b && it != vecValue.end() && itRef != vecExpectedValue.end()){ |
47 |
1/1✓ Branch 0 (34→35) taken 2 times.
|
4 | b &= it->getValue() == *itRef; |
48 |
8/8✓ Branch 0 (36→37) taken 2 times.
✓ Branch 2 (39→40) taken 2 times.
✓ Branch 4 (40→41) taken 2 times.
✓ Branch 6 (41→42) taken 2 times.
✓ Branch 8 (44→45) taken 2 times.
✓ Branch 10 (45→46) taken 2 times.
✓ Branch 12 (46→47) taken 2 times.
✓ Branch 14 (47→48) taken 2 times.
|
6 | std::cout << "\tvalue = '" << it->getValue() << "', reference = '"<< *itRef << "', isOk = " << b << std::endl; |
49 | ++it; | ||
50 | ++itRef; | ||
51 | } | ||
52 |
3/3✓ Branch 0 (73→74) taken 1 times.
✓ Branch 2 (74→75) taken 1 times.
✓ Branch 4 (75→76) taken 1 times.
|
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 |
2/2✓ Branch 0 (4→5) taken 1 times.
✓ Branch 2 (5→6) taken 1 times.
|
1 | checkKeyMapValue(NULL, ""); |
59 | 1 | std::vector<std::string> vecNoValue; | |
60 |
1/1✓ Branch 0 (9→10) taken 1 times.
|
1 | checkKeyMapVecValue(NULL, vecNoValue); |
61 | 1 | } | |
62 | |||
63 | ///Check the YML parser | ||
64 | 1 | void checkParserYml(){ | |
65 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | PPath ymlFile(FULL_YML_CONFIG); |
66 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | DicoValue dico; |
67 |
2/3✓ Branch 0 (6→7) taken 1 times.
✗ Branch 2 (7→8) not taken.
✓ Branch 3 (7→9) taken 1 times.
|
1 | assert(parser_yml(dico, ymlFile)); |
68 |
2/2✓ Branch 0 (9→10) taken 1 times.
✓ Branch 2 (10→11) taken 1 times.
|
1 | const DicoValue * mapJob = dico.getMap("job"); |
69 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | assert(mapJob != NULL); |
70 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→53) not taken.
|
1 | if(mapJob != NULL){ |
71 |
2/2✓ Branch 0 (15→16) taken 1 times.
✓ Branch 2 (16→17) taken 1 times.
|
1 | const DicoValue * mapJobArgument = mapJob->getMap("job_argument"); |
72 |
3/4✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
✗ Branch 4 (22→23) not taken.
✓ Branch 5 (22→24) taken 1 times.
|
1 | assert(checkKeyMapValue(mapJobArgument, "-A aswg -p short")); |
73 | |||
74 |
2/2✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (27→28) taken 1 times.
|
1 | const DicoValue * mapRmDL1 = mapJob->getMap("rmdl1"); |
75 |
1/2✗ Branch 0 (29→30) not taken.
✓ Branch 1 (29→31) taken 1 times.
|
1 | assert(mapRmDL1 != NULL); |
76 |
1/2✓ Branch 0 (31→32) taken 1 times.
✗ Branch 1 (31→53) not taken.
|
1 | if(mapRmDL1 != NULL){ |
77 |
2/2✓ Branch 0 (32→33) taken 1 times.
✓ Branch 2 (33→34) taken 1 times.
|
1 | const DicoValue * mapDemendencies = mapRmDL1->getMap("depdendencies"); |
78 | |||
79 | 1 | std::vector<std::string> vecExpectedValue; | |
80 |
2/2✓ Branch 0 (38→39) taken 1 times.
✓ Branch 2 (39→40) taken 1 times.
|
2 | vecExpectedValue.push_back("dl1dl2"); |
81 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | vecExpectedValue.push_back("plotdl1"); |
82 |
2/3✓ Branch 0 (48→49) taken 1 times.
✗ Branch 2 (49→50) not taken.
✓ Branch 3 (49→51) taken 1 times.
|
1 | assert(checkKeyMapVecValue(mapDemendencies, vecExpectedValue)); |
83 | 1 | } | |
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 | |||
94 |