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 "phoenix_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 | 14 | bool checkKeyMapValue(const DicoValue * mapKey, const std::string & expectedValue){ | |
17 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→9) taken 13 times.
|
14 | if(mapKey == NULL){ |
18 | 1 | std::cout << "checkKeyMapValue : map NULL for expectedValue = '"<<expectedValue<<"'" << std::endl; | |
19 | 1 | return expectedValue == ""; | |
20 | } | ||
21 | // std::cout << "checkKeyMapValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', expectedValue = '"<<expectedValue<<"'" << std::endl; | ||
22 | 13 | bool b(mapKey->getValue() == expectedValue); | |
23 | // std::cout << "checkKeyMapValue : b = " << b << std::endl; | ||
24 | 13 | return b; | |
25 | } | ||
26 | |||
27 | ///Check the value of a DicoValue | ||
28 | /** @param mapKey : DicoValue to be checked | ||
29 | * @param expectedValue : expected value | ||
30 | * @return true if the value matches the expectedValue, false otherwise | ||
31 | */ | ||
32 | 7 | 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 6 times.
|
7 | 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 | // std::cout << "checkKeyMapVecValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', vecExpectedValue = " << std::endl; | ||
39 | // phoenix_print(vecExpectedValue); | ||
40 | 6 | bool b(true); | |
41 |
1/1✓ Branch 0 (7→8) taken 6 times.
|
6 | const VecDicoValue & vecValue = mapKey->getVecChild(); |
42 | 6 | b &= vecValue.size() == vecExpectedValue.size(); | |
43 | // std::cout << "checkKeyMapVecValue : vecValue.size() = " << vecValue.size() << ", vecExpectedValue.size() = "<< vecExpectedValue.size() << ", isOk = " << b << std::endl; | ||
44 | 6 | VecDicoValue::const_iterator it(vecValue.begin()); | |
45 | 6 | std::vector<std::string>::const_iterator itRef(vecExpectedValue.begin()); | |
46 |
6/8✓ Branch 0 (24→25) taken 27 times.
✗ Branch 1 (24→42) not taken.
✓ Branch 2 (32→33) taken 21 times.
✓ Branch 3 (32→42) taken 6 times.
✓ Branch 4 (40→41) taken 21 times.
✗ Branch 5 (40→42) not taken.
✓ Branch 6 (43→13) taken 21 times.
✓ Branch 7 (43→44) taken 6 times.
|
75 | while(b && it != vecValue.end() && itRef != vecExpectedValue.end()){ |
47 |
1/1✓ Branch 0 (17→18) taken 21 times.
|
42 | b &= it->getValue() == *itRef; |
48 | // std::cout << "\tvalue = '" << it->getValue() << "', reference = '"<< *itRef << "', isOk = " << b << std::endl; | ||
49 | ++it; | ||
50 | ++itRef; | ||
51 | } | ||
52 | // std::cout << "checkKeyMapVecValue : b = " << b << std::endl; | ||
53 | 6 | 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 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("key: value\nother_key: \"some string in double quotes\"\n\nthird_key: 'now we use simple quotes'\n\n\nfourth_key: finally we used nothing to fill the value of this key\n\n\n"); |
66 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath ymlFile("test.yml"); |
67 |
5/5✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
✓ Branch 8 (16→17) taken 1 times.
|
5 | phoenix_assert(ymlFile.saveFileContent(fileContent)); |
68 | |||
69 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | DicoValue dico; |
70 |
5/5✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (29→30) taken 1 times.
✓ Branch 4 (32→33) taken 1 times.
✓ Branch 6 (33→34) taken 1 times.
✓ Branch 8 (34→35) taken 1 times.
|
5 | phoenix_assert(parser_yml(dico, ymlFile)); |
71 | // std::cout << "checkParserYml : output DicoValue :" << std::endl; | ||
72 | // dico.print(); | ||
73 | |||
74 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | DicoValue * mapKey = dico.getMap("key"); |
75 | // bool isKeyExist = mapKey != NULL; | ||
76 | // std::cout << "checkParserYml : isKeyExist = " << isKeyExist << std::endl; | ||
77 |
6/6✓ Branch 0 (46→47) taken 1 times.
✓ Branch 2 (49→50) taken 1 times.
✓ Branch 4 (52→53) taken 1 times.
✓ Branch 6 (55→56) taken 1 times.
✓ Branch 8 (56→57) taken 1 times.
✓ Branch 10 (57→58) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapKey, "value")); |
78 | |||
79 |
2/2✓ Branch 0 (66→67) taken 1 times.
✓ Branch 2 (67→68) taken 1 times.
|
1 | DicoValue * mapOtherKey = dico.getMap("other_key"); |
80 | // bool isOtherKeyExist = mapOtherKey != NULL; | ||
81 | // std::cout << "checkParserYml : isOtherKeyExist = " << isOtherKeyExist << std::endl; | ||
82 |
6/6✓ Branch 0 (71→72) taken 1 times.
✓ Branch 2 (74→75) taken 1 times.
✓ Branch 4 (77→78) taken 1 times.
✓ Branch 6 (80→81) taken 1 times.
✓ Branch 8 (81→82) taken 1 times.
✓ Branch 10 (82→83) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapOtherKey, "\"some string in double quotes\"")); |
83 | |||
84 |
2/2✓ Branch 0 (91→92) taken 1 times.
✓ Branch 2 (92→93) taken 1 times.
|
1 | DicoValue * mapThirdKey = dico.getMap("third_key"); |
85 | // bool isThirdKeyExist = mapThirdKey != NULL; | ||
86 | // std::cout << "checkParserYml : isThirdKeyExist = " << isThirdKeyExist << std::endl; | ||
87 |
6/6✓ Branch 0 (96→97) taken 1 times.
✓ Branch 2 (99→100) taken 1 times.
✓ Branch 4 (102→103) taken 1 times.
✓ Branch 6 (105→106) taken 1 times.
✓ Branch 8 (106→107) taken 1 times.
✓ Branch 10 (107→108) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapThirdKey, "'now we use simple quotes'")); |
88 | |||
89 |
2/2✓ Branch 0 (116→117) taken 1 times.
✓ Branch 2 (117→118) taken 1 times.
|
1 | DicoValue * mapFourthKey = dico.getMap("fourth_key"); |
90 | // bool isFourthKeyExist = mapFourthKey != NULL; | ||
91 | // std::cout << "checkParserYml : isFourthKeyExist = " << isFourthKeyExist << std::endl; | ||
92 |
6/6✓ Branch 0 (121→122) taken 1 times.
✓ Branch 2 (124→125) taken 1 times.
✓ Branch 4 (127→128) taken 1 times.
✓ Branch 6 (130→131) taken 1 times.
✓ Branch 8 (131→132) taken 1 times.
✓ Branch 10 (132→133) taken 1 times.
|
8 | phoenix_assert(checkKeyMapValue(mapFourthKey, "finally we used nothing to fill the value of this key")); |
93 | |||
94 |
8/8✓ Branch 0 (143→144) taken 1 times.
✓ Branch 2 (146→147) taken 1 times.
✓ Branch 4 (149→150) taken 1 times.
✓ Branch 6 (150→151) taken 1 times.
✓ Branch 8 (151→152) taken 1 times.
✓ Branch 10 (152→153) taken 1 times.
✓ Branch 12 (153→154) taken 1 times.
✓ Branch 14 (154→155) taken 1 times.
|
6 | phoenix_assert(phoenix_get_string(dico, "key", "default") == "value"); |
95 |
8/8✓ Branch 0 (166→167) taken 1 times.
✓ Branch 2 (169→170) taken 1 times.
✓ Branch 4 (172→173) taken 1 times.
✓ Branch 6 (173→174) taken 1 times.
✓ Branch 8 (174→175) taken 1 times.
✓ Branch 10 (175→176) taken 1 times.
✓ Branch 12 (176→177) taken 1 times.
✓ Branch 14 (177→178) taken 1 times.
|
6 | phoenix_assert(phoenix_get_string(dico, "unexistingkey", "default") == "default"); |
96 | |||
97 |
6/6✓ Branch 0 (189→190) taken 1 times.
✓ Branch 2 (192→193) taken 1 times.
✓ Branch 4 (195→196) taken 1 times.
✓ Branch 6 (196→197) taken 1 times.
✓ Branch 8 (197→198) taken 1 times.
✓ Branch 10 (198→199) taken 1 times.
|
6 | phoenix_assert(phoenix_load_value_from_config<bool>(dico, "key", false) == false); |
98 |
6/6✓ Branch 0 (208→209) taken 1 times.
✓ Branch 2 (211→212) taken 1 times.
✓ Branch 4 (214→215) taken 1 times.
✓ Branch 6 (215→216) taken 1 times.
✓ Branch 8 (216→217) taken 1 times.
✓ Branch 10 (217→218) taken 1 times.
|
5 | phoenix_assert(phoenix_load_value_from_config<bool>(dico, "unexistingkey", false) == false); |
99 | 1 | } | |
100 | |||
101 | ///Check the embeded dico | ||
102 | 1 | void checkEmbededDico(){ | |
103 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("main:\n\tsub_key: VALUE\n\tother_sub_key: \"some string in double quotes\"\n\nnot_in_main_key: VALUE_IN_UPPERCASE\n\n\n"); |
104 | |||
105 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath ymlFile("test_embeded_dico.yml"); |
106 |
5/5✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
✓ Branch 8 (16→17) taken 1 times.
|
5 | phoenix_assert(ymlFile.saveFileContent(fileContent)); |
107 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | DicoValue dico; |
108 |
5/5✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (29→30) taken 1 times.
✓ Branch 4 (32→33) taken 1 times.
✓ Branch 6 (33→34) taken 1 times.
✓ Branch 8 (34→35) taken 1 times.
|
5 | phoenix_assert(parser_yml(dico, ymlFile)); |
109 | // std::cout << "checkEmbededDico : output DicoValue :" << std::endl; | ||
110 | // dico.print(); | ||
111 | |||
112 | // MapDicoValue & mapChld = dico.getMapChild(); | ||
113 | // std::cerr << "checkEmbededDico : nb key = " << mapChld.size() << std::endl; | ||
114 | // for(MapDicoValue::iterator it(mapChld.begin()); it != mapChld.end(); ++it){ | ||
115 | // std::cerr << "\tkey '"<<it->first<<"'" << std::endl; | ||
116 | // } | ||
117 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | DicoValue * mapMain = dico.getMap("main"); |
118 | // std::cout << "checkEmbededDico : mapMain = " << mapMain << std::endl; | ||
119 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→96) not taken.
|
1 | if(mapMain != NULL){ |
120 |
2/2✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
|
1 | DicoValue * mapSubKey = mapMain->getMap("sub_key"); |
121 |
6/6✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (56→57) taken 1 times.
✓ Branch 6 (59→60) taken 1 times.
✓ Branch 8 (60→61) taken 1 times.
✓ Branch 10 (61→62) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapSubKey, "VALUE")); |
122 |
2/2✓ Branch 0 (70→71) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
|
1 | DicoValue * mapOtherSubKey = mapMain->getMap("other_sub_key"); |
123 |
6/6✓ Branch 0 (75→76) taken 1 times.
✓ Branch 2 (78→79) taken 1 times.
✓ Branch 4 (81→82) taken 1 times.
✓ Branch 6 (84→85) taken 1 times.
✓ Branch 8 (85→86) taken 1 times.
✓ Branch 10 (86→87) taken 1 times.
|
8 | phoenix_assert(checkKeyMapValue(mapOtherSubKey, "\"some string in double quotes\"")); |
124 | } | ||
125 |
4/4✓ Branch 0 (98→99) taken 1 times.
✓ Branch 2 (101→102) taken 1 times.
✓ Branch 4 (104→105) taken 1 times.
✓ Branch 6 (105→106) taken 1 times.
|
5 | phoenix_assert(mapMain != NULL); |
126 | |||
127 |
2/2✓ Branch 0 (112→113) taken 1 times.
✓ Branch 2 (113→114) taken 1 times.
|
1 | DicoValue * mapNotInMainKey = dico.getMap("not_in_main_key"); |
128 | // bool isNotInMainKeyExist = mapNotInMainKey != NULL; | ||
129 | // std::cout << "checkEmbededDico : isNotInMainKeyExist = " << isNotInMainKeyExist << std::endl; | ||
130 |
6/6✓ Branch 0 (117→118) taken 1 times.
✓ Branch 2 (120→121) taken 1 times.
✓ Branch 4 (123→124) taken 1 times.
✓ Branch 6 (126→127) taken 1 times.
✓ Branch 8 (127→128) taken 1 times.
✓ Branch 10 (128→129) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapNotInMainKey, "VALUE_IN_UPPERCASE")); |
131 | 1 | } | |
132 | |||
133 | ///Check the embeded dico | ||
134 | 1 | void checkCompactList(){ | |
135 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("some_list: [one, two, three]\nother_key: VALUE_IN_UPPERCASE\nother_list: [\"value in double quotes\",'value in simple quote', \"value 2 in double quotes\", 'value 2 in simple quote']\n\n"); |
136 | |||
137 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath ymlFile("test_compact_list.yml"); |
138 |
5/5✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
✓ Branch 8 (16→17) taken 1 times.
|
5 | phoenix_assert(ymlFile.saveFileContent(fileContent)); |
139 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | DicoValue dico; |
140 |
5/5✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (29→30) taken 1 times.
✓ Branch 4 (32→33) taken 1 times.
✓ Branch 6 (33→34) taken 1 times.
✓ Branch 8 (34→35) taken 1 times.
|
5 | phoenix_assert(parser_yml(dico, ymlFile)); |
141 | // std::cout << "checkCompactList : output DicoValue :" << std::endl; | ||
142 | // dico.print(); | ||
143 | |||
144 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | DicoValue * mapSomeListKey = dico.getMap("some_list"); |
145 | // bool isSomeListExist = mapSomeListKey != NULL; | ||
146 | // std::cout << "checkCompactList : isSomeListExist = " << isSomeListExist << std::endl; | ||
147 | |||
148 | 1 | std::vector<std::string> vecExpectedValue; | |
149 |
2/2✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (48→49) taken 1 times.
|
2 | vecExpectedValue.push_back("one"); |
150 |
2/2✓ Branch 0 (53→54) taken 1 times.
✓ Branch 2 (54→55) taken 1 times.
|
2 | vecExpectedValue.push_back("two"); |
151 |
2/2✓ Branch 0 (59→60) taken 1 times.
✓ Branch 2 (60→61) taken 1 times.
|
2 | vecExpectedValue.push_back("three"); |
152 |
5/5✓ Branch 0 (65→66) taken 1 times.
✓ Branch 2 (68→69) taken 1 times.
✓ Branch 4 (71→72) taken 1 times.
✓ Branch 6 (72→73) taken 1 times.
✓ Branch 8 (73→74) taken 1 times.
|
5 | phoenix_assert(checkKeyMapVecValue(mapSomeListKey, vecExpectedValue)); |
153 | |||
154 |
2/2✓ Branch 0 (80→81) taken 1 times.
✓ Branch 2 (81→82) taken 1 times.
|
1 | DicoValue * mapOtherKey = dico.getMap("other_key"); |
155 | // bool isOtherKeyExist = mapOtherKey != NULL; | ||
156 | // std::cout << "checkCompactList : isOtherKeyExist = " << isOtherKeyExist << std::endl; | ||
157 |
6/6✓ Branch 0 (85→86) taken 1 times.
✓ Branch 2 (88→89) taken 1 times.
✓ Branch 4 (91→92) taken 1 times.
✓ Branch 6 (94→95) taken 1 times.
✓ Branch 8 (95→96) taken 1 times.
✓ Branch 10 (96→97) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapOtherKey, "VALUE_IN_UPPERCASE")); |
158 | |||
159 |
2/2✓ Branch 0 (105→106) taken 1 times.
✓ Branch 2 (106→107) taken 1 times.
|
1 | DicoValue * mapOtherListKey = dico.getMap("other_list"); |
160 |
4/4✓ Branch 0 (110→111) taken 1 times.
✓ Branch 2 (113→114) taken 1 times.
✓ Branch 4 (116→117) taken 1 times.
✓ Branch 6 (117→118) taken 1 times.
|
5 | phoenix_assert(mapOtherListKey != NULL); |
161 | |||
162 | 1 | std::vector<std::string> vecOtherExpectedValue; | |
163 |
2/2✓ Branch 0 (127→128) taken 1 times.
✓ Branch 2 (128→129) taken 1 times.
|
2 | vecOtherExpectedValue.push_back("\"value in double quotes\""); |
164 |
2/2✓ Branch 0 (133→134) taken 1 times.
✓ Branch 2 (134→135) taken 1 times.
|
2 | vecOtherExpectedValue.push_back("'value in simple quote'"); |
165 |
2/2✓ Branch 0 (139→140) taken 1 times.
✓ Branch 2 (140→141) taken 1 times.
|
2 | vecOtherExpectedValue.push_back("\"value 2 in double quotes\""); |
166 |
2/2✓ Branch 0 (145→146) taken 1 times.
✓ Branch 2 (146→147) taken 1 times.
|
2 | vecOtherExpectedValue.push_back("'value 2 in simple quote'"); |
167 |
5/5✓ Branch 0 (151→152) taken 1 times.
✓ Branch 2 (154→155) taken 1 times.
✓ Branch 4 (157→158) taken 1 times.
✓ Branch 6 (158→159) taken 1 times.
✓ Branch 8 (159→160) taken 1 times.
|
5 | phoenix_assert(checkKeyMapVecValue(mapOtherListKey, vecOtherExpectedValue)); |
168 | 1 | } | |
169 | |||
170 | ///Check the embeded dico | ||
171 | /** @param fileNameYml : file name to be written | ||
172 | * @param contentYml : content of the file to be written | ||
173 | */ | ||
174 | 2 | void checkDashedList(const PPath & fileNameYml, const PString & contentYml){ | |
175 |
5/5✓ Branch 0 (4→5) taken 2 times.
✓ Branch 2 (7→8) taken 2 times.
✓ Branch 4 (10→11) taken 2 times.
✓ Branch 6 (11→12) taken 2 times.
✓ Branch 8 (12→13) taken 2 times.
|
10 | phoenix_assert(fileNameYml.saveFileContent(contentYml)); |
176 |
1/1✓ Branch 0 (19→20) taken 2 times.
|
2 | DicoValue dico; |
177 |
5/5✓ Branch 0 (22→23) taken 2 times.
✓ Branch 2 (25→26) taken 2 times.
✓ Branch 4 (28→29) taken 2 times.
✓ Branch 6 (29→30) taken 2 times.
✓ Branch 8 (30→31) taken 2 times.
|
10 | phoenix_assert(parser_yml(dico, fileNameYml)); |
178 | // std::cout << "checkDashedList : output DicoValue :" << std::endl; | ||
179 | // dico.print(); | ||
180 |
2/2✓ Branch 0 (37→38) taken 2 times.
✓ Branch 2 (38→39) taken 2 times.
|
2 | DicoValue * mapSomeListKey = dico.getMap("some_list"); |
181 | // bool isSomeListExist = mapSomeListKey != NULL; | ||
182 | // std::cout << "checkDashedList : isSomeListExist = " << isSomeListExist << std::endl; | ||
183 | |||
184 | 2 | std::vector<std::string> vecExpectedValue; | |
185 |
2/2✓ Branch 0 (43→44) taken 2 times.
✓ Branch 2 (44→45) taken 2 times.
|
4 | vecExpectedValue.push_back("one"); |
186 |
2/2✓ Branch 0 (49→50) taken 2 times.
✓ Branch 2 (50→51) taken 2 times.
|
4 | vecExpectedValue.push_back("two"); |
187 |
2/2✓ Branch 0 (55→56) taken 2 times.
✓ Branch 2 (56→57) taken 2 times.
|
4 | vecExpectedValue.push_back("three"); |
188 |
5/5✓ Branch 0 (61→62) taken 2 times.
✓ Branch 2 (64→65) taken 2 times.
✓ Branch 4 (67→68) taken 2 times.
✓ Branch 6 (68→69) taken 2 times.
✓ Branch 8 (69→70) taken 2 times.
|
12 | phoenix_assert(checkKeyMapVecValue(mapSomeListKey, vecExpectedValue)); |
189 | |||
190 |
6/6✓ Branch 0 (78→79) taken 2 times.
✓ Branch 2 (81→82) taken 2 times.
✓ Branch 4 (84→85) taken 2 times.
✓ Branch 6 (85→86) taken 2 times.
✓ Branch 8 (86→87) taken 2 times.
✓ Branch 10 (88→89) taken 2 times.
|
12 | phoenix_assert(phoenix_get_vecstring(dico, "some_unexisting_list").size() == 0lu); |
191 |
6/6✓ Branch 0 (99→100) taken 2 times.
✓ Branch 2 (102→103) taken 2 times.
✓ Branch 4 (105→106) taken 2 times.
✓ Branch 6 (106→107) taken 2 times.
✓ Branch 8 (107→108) taken 2 times.
✓ Branch 10 (109→110) taken 2 times.
|
12 | phoenix_assert(phoenix_get_vecstring(dico, "some_list").size() == 3lu); |
192 |
6/6✓ Branch 0 (120→121) taken 2 times.
✓ Branch 2 (123→124) taken 2 times.
✓ Branch 4 (126→127) taken 2 times.
✓ Branch 6 (127→128) taken 2 times.
✓ Branch 8 (128→129) taken 2 times.
✓ Branch 10 (130→131) taken 2 times.
|
10 | phoenix_assert(phoenix_load_vecValue_from_config<std::string>(dico, "some_list").size() == 3lu); |
193 | |||
194 |
2/2✓ Branch 0 (139→140) taken 2 times.
✓ Branch 2 (140→141) taken 2 times.
|
2 | DicoValue * mapOtherKey = dico.getMap("other_key"); |
195 | // bool isOtherKeyExist = mapOtherKey != NULL; | ||
196 | // std::cout << "checkDashedList : isOtherKeyExist = " << isOtherKeyExist << std::endl; | ||
197 |
6/6✓ Branch 0 (144→145) taken 2 times.
✓ Branch 2 (147→148) taken 2 times.
✓ Branch 4 (150→151) taken 2 times.
✓ Branch 6 (153→154) taken 2 times.
✓ Branch 8 (154→155) taken 2 times.
✓ Branch 10 (155→156) taken 2 times.
|
14 | phoenix_assert(checkKeyMapValue(mapOtherKey, "VALUE_IN_UPPERCASE")); |
198 | |||
199 |
2/2✓ Branch 0 (164→165) taken 2 times.
✓ Branch 2 (165→166) taken 2 times.
|
2 | DicoValue * mapOtherListKey = dico.getMap("other_list"); |
200 | // bool isOtherListExist = mapOtherListKey != NULL; | ||
201 | // std::cout << "checkDashedList : isOtherListExist = " << isOtherListExist << std::endl; | ||
202 | |||
203 | 2 | std::vector<std::string> vecOtherExpectedValue; | |
204 |
2/2✓ Branch 0 (170→171) taken 2 times.
✓ Branch 2 (171→172) taken 2 times.
|
4 | vecOtherExpectedValue.push_back("\"value in double quotes\""); |
205 |
2/2✓ Branch 0 (176→177) taken 2 times.
✓ Branch 2 (177→178) taken 2 times.
|
4 | vecOtherExpectedValue.push_back("'value in simple quote'"); |
206 |
2/2✓ Branch 0 (182→183) taken 2 times.
✓ Branch 2 (183→184) taken 2 times.
|
4 | vecOtherExpectedValue.push_back("\"value 2 in double quotes\""); |
207 |
2/2✓ Branch 0 (188→189) taken 2 times.
✓ Branch 2 (189→190) taken 2 times.
|
4 | vecOtherExpectedValue.push_back("'value 2 in simple quote'"); |
208 |
5/5✓ Branch 0 (194→195) taken 2 times.
✓ Branch 2 (197→198) taken 2 times.
✓ Branch 4 (200→201) taken 2 times.
✓ Branch 6 (201→202) taken 2 times.
✓ Branch 8 (202→203) taken 2 times.
|
10 | phoenix_assert(checkKeyMapVecValue(mapOtherListKey, vecOtherExpectedValue)); |
209 | 2 | } | |
210 | |||
211 | ///Check the embeded dico | ||
212 | 1 | void checkCompactDico(){ | |
213 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("main:{\n\tsub_key: VALUE,\n\tother_sub_key: \"some string in double quotes\"\n}\nnot_in_main_key: VALUE_IN_UPPERCASE\n\n\n"); |
214 | |||
215 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath ymlFile("test_compact_dico.yml"); |
216 |
5/5✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
✓ Branch 8 (16→17) taken 1 times.
|
5 | phoenix_assert(ymlFile.saveFileContent(fileContent)); |
217 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | DicoValue dico; |
218 |
5/5✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (29→30) taken 1 times.
✓ Branch 4 (32→33) taken 1 times.
✓ Branch 6 (33→34) taken 1 times.
✓ Branch 8 (34→35) taken 1 times.
|
5 | phoenix_assert(parser_yml(dico, ymlFile)); |
219 | // std::cout << "checkCompactDico : output DicoValue :" << std::endl; | ||
220 | // dico.print(); | ||
221 | |||
222 | // MapDicoValue & mapChld = dico.getMapChild(); | ||
223 | // std::cerr << "checkCompphoenix_assertactDico : nb key = " << mapChld.size() << std::endl; | ||
224 | // for(MapDicoValue::iterator it(mapChld.begin()); it != mapChld.end(); ++it){ | ||
225 | // std::cerr << "\tkey '"<<it->first<<"'" << std::endl; | ||
226 | // } | ||
227 | |||
228 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | DicoValue * mapMain = dico.getMap("main"); |
229 | // std::cout << "checkCompactDico : mapMain = " << mapMain << std::endl; | ||
230 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→96) not taken.
|
1 | if(mapMain != NULL){ |
231 |
2/2✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
|
1 | DicoValue * mapSubKey = mapMain->getMap("sub_key"); |
232 |
6/6✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (56→57) taken 1 times.
✓ Branch 6 (59→60) taken 1 times.
✓ Branch 8 (60→61) taken 1 times.
✓ Branch 10 (61→62) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapSubKey, "VALUE")); |
233 |
2/2✓ Branch 0 (70→71) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
|
1 | DicoValue * mapOtherSubKey = mapMain->getMap("other_sub_key"); |
234 |
6/6✓ Branch 0 (75→76) taken 1 times.
✓ Branch 2 (78→79) taken 1 times.
✓ Branch 4 (81→82) taken 1 times.
✓ Branch 6 (84→85) taken 1 times.
✓ Branch 8 (85→86) taken 1 times.
✓ Branch 10 (86→87) taken 1 times.
|
8 | phoenix_assert(checkKeyMapValue(mapOtherSubKey, "\"some string in double quotes\"")); |
235 | } | ||
236 |
4/4✓ Branch 0 (98→99) taken 1 times.
✓ Branch 2 (101→102) taken 1 times.
✓ Branch 4 (104→105) taken 1 times.
✓ Branch 6 (105→106) taken 1 times.
|
5 | phoenix_assert(mapMain != NULL); |
237 | |||
238 |
2/2✓ Branch 0 (112→113) taken 1 times.
✓ Branch 2 (113→114) taken 1 times.
|
1 | DicoValue * mapNotInMainKey = dico.getMap("not_in_main_key"); |
239 | // bool isNotInMainKeyExist = mapNotInMainKey != NULL; | ||
240 | // std::cout << "checkCompactDico : isNotInMainKeyExist = " << isNotInMainKeyExist << std::endl; | ||
241 |
6/6✓ Branch 0 (117→118) taken 1 times.
✓ Branch 2 (120→121) taken 1 times.
✓ Branch 4 (123→124) taken 1 times.
✓ Branch 6 (126→127) taken 1 times.
✓ Branch 8 (127→128) taken 1 times.
✓ Branch 10 (128→129) taken 1 times.
|
7 | phoenix_assert(checkKeyMapValue(mapNotInMainKey, "VALUE_IN_UPPERCASE")); |
242 | 1 | } | |
243 | |||
244 | 1 | int main(int argc, char** argv){ | |
245 | 1 | testCheckValue(); | |
246 | 1 | checkParserYml(); | |
247 | 1 | checkEmbededDico(); | |
248 | 1 | checkCompactList(); | |
249 |
4/4✓ Branch 0 (6→7) taken 1 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 4 (8→9) taken 1 times.
✓ Branch 6 (9→10) taken 1 times.
|
1 | checkDashedList(PPath("test_dashed_list.yml"), "some_list:\n\t- one\n\t- two\n\t- three\nother_key: VALUE_IN_UPPERCASE\nother_list:\n\t- \"value in double quotes\"\n\t- 'value in simple quote'\n\t- \"value 2 in double quotes\"\n\t- 'value 2 in simple quote'\n\n"); |
250 |
4/4✓ 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.
|
1 | checkDashedList(PPath("test_dashed_list_noIndent.yml"), "some_list:\n- one\n- two\n- three\nother_key: VALUE_IN_UPPERCASE\nother_list:\n\t- \"value in double quotes\"\n\t- 'value in simple quote'\n\t- \"value 2 in double quotes\"\n\t- 'value 2 in simple quote'\n\n"); |
251 | 1 | checkCompactDico(); | |
252 | 1 | return 0; | |
253 | } | ||
254 | |||
255 | |||
256 |