Directory: | ./ |
---|---|
File: | tmp_project/PhoenixYml/TESTS/TEST_PARSER_YML/main_full_config.cpp |
Date: | 2025-03-27 14:50:11 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 54 | 54 | 100.0% |
Branches: | 74 | 83 | 89.2% |
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 taken 1 times.
✓ Branch 1 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 |
5/5✓ Branch 6 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 18 taken 1 times.
|
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/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if(mapKey == NULL){ |
34 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 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 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 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 1 taken 1 times.
|
1 | const VecDicoValue & vecValue = mapKey->getVecChild(); |
42 | 1 | b &= vecValue.size() == vecExpectedValue.size(); | |
43 |
7/7✓ Branch 1 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 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 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 1 times.
|
3 | while(b && it != vecValue.end() && itRef != vecExpectedValue.end()){ |
47 |
1/1✓ Branch 3 taken 2 times.
|
2 | b &= it->getValue() == *itRef; |
48 |
8/8✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 15 taken 2 times.
✓ Branch 18 taken 2 times.
✓ Branch 21 taken 2 times.
✓ Branch 24 taken 2 times.
|
2 | std::cout << "\tvalue = '" << it->getValue() << "', reference = '"<< *itRef << "', isOk = " << b << std::endl; |
49 | 2 | ++it; | |
50 | 2 | ++itRef; | |
51 | } | ||
52 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 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 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkKeyMapValue(NULL, ""); |
59 | 1 | std::vector<std::string> vecNoValue; | |
60 |
1/1✓ Branch 1 taken 1 times.
|
1 | checkKeyMapVecValue(NULL, vecNoValue); |
61 | 1 | } | |
62 | |||
63 | ///Check the YML parser | ||
64 | 1 | void checkParserYml(){ | |
65 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath ymlFile(FULL_YML_CONFIG); |
66 |
1/1✓ Branch 1 taken 1 times.
|
1 | DicoValue dico; |
67 |
2/3✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | assert(parser_yml(dico, ymlFile)); |
68 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | const DicoValue * mapJob = dico.getMap("job"); |
69 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(mapJob != NULL); |
70 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(mapJob != NULL){ |
71 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | const DicoValue * mapJobArgument = mapJob->getMap("job_argument"); |
72 |
3/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
|
1 | assert(checkKeyMapValue(mapJobArgument, "-A aswg -p short")); |
73 | |||
74 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | const DicoValue * mapRmDL1 = mapJob->getMap("rmdl1"); |
75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(mapRmDL1 != NULL); |
76 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(mapRmDL1 != NULL){ |
77 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | const DicoValue * mapDemendencies = mapRmDL1->getMap("depdendencies"); |
78 | |||
79 | 1 | std::vector<std::string> vecExpectedValue; | |
80 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecExpectedValue.push_back("dl1dl2"); |
81 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecExpectedValue.push_back("plotdl1"); |
82 |
2/3✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 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 |