| 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 "phoenix_check.h" | ||
| 10 | #include "parser_toml.h" | ||
| 11 | |||
| 12 | ///Check the value of a ConfigNode | ||
| 13 | /** @param mapKey : ConfigNode to be checked | ||
| 14 | * @param expectedValue : expected value | ||
| 15 | * @return true if the value matches the expectedValue, false otherwise | ||
| 16 | */ | ||
| 17 | 27 | bool checkKeyMapValue(const ConfigNode * mapKey, const PString & expectedValue){ | |
| 18 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→9) taken 26 times.
|
27 | if(mapKey == NULL){ |
| 19 | 1 | std::cout << "checkKeyMapValue : map NULL for expectedValue = '"<<expectedValue<<"'" << std::endl; | |
| 20 | 1 | return expectedValue == ""; | |
| 21 | } | ||
| 22 | // std::cout << "checkKeyMapValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', expectedValue = '"<<expectedValue<<"'" << std::endl; | ||
| 23 | 26 | bool b(mapKey->getValue() == expectedValue); | |
| 24 | // std::cout << "checkKeyMapValue : b = " << b << std::endl; | ||
| 25 | 26 | return b; | |
| 26 | } | ||
| 27 | |||
| 28 | ///Check the value of a ConfigNode | ||
| 29 | /** @param mapKey : ConfigNode to be checked | ||
| 30 | * @param expectedValue : expected value | ||
| 31 | * @return true if the value matches the expectedValue, false otherwise | ||
| 32 | */ | ||
| 33 | 3 | bool checkKeyMapVecValue(const ConfigNode * mapKey, const PVecString & vecExpectedValue){ | |
| 34 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→7) taken 2 times.
|
3 | if(mapKey == NULL){ |
| 35 |
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; |
| 36 | // phoenix_print(vecExpectedValue); | ||
| 37 | 1 | return vecExpectedValue.size() == 0lu; | |
| 38 | } | ||
| 39 | // std::cout << "checkKeyMapVecValue : map '"<<mapKey->getKey()<<"' => '"<<mapKey->getValue()<<"', vecExpectedValue = " << std::endl; | ||
| 40 | // phoenix_print(vecExpectedValue); | ||
| 41 | 2 | bool b(true); | |
| 42 |
1/1✓ Branch 0 (7→8) taken 2 times.
|
2 | const VecConfigNode & vecValue = mapKey->getVecChild(); |
| 43 | 2 | b &= vecValue.size() == vecExpectedValue.size(); | |
| 44 | // std::cout << "checkKeyMapVecValue : vecValue.size() = " << vecValue.size() << ", vecExpectedValue.size() = "<< vecExpectedValue.size() << ", isOk = " << b << std::endl; | ||
| 45 | 2 | VecConfigNode::const_iterator it(vecValue.begin()); | |
| 46 | 2 | PVecString::const_iterator itRef(vecExpectedValue.begin()); | |
| 47 |
6/8✓ Branch 0 (36→37) taken 9 times.
✗ Branch 1 (36→54) not taken.
✓ Branch 2 (44→45) taken 7 times.
✓ Branch 3 (44→54) taken 2 times.
✓ Branch 4 (52→53) taken 7 times.
✗ Branch 5 (52→54) not taken.
✓ Branch 6 (55→13) taken 7 times.
✓ Branch 7 (55→56) taken 2 times.
|
25 | while(b && it != vecValue.end() && itRef != vecExpectedValue.end()){ |
| 48 |
1/1✓ Branch 0 (17→18) taken 7 times.
|
14 | b &= (*it)->getValue() == *itRef; |
| 49 |
8/8✓ Branch 0 (19→20) taken 7 times.
✓ Branch 2 (22→23) taken 7 times.
✓ Branch 4 (23→24) taken 7 times.
✓ Branch 6 (24→25) taken 7 times.
✓ Branch 8 (27→28) taken 7 times.
✓ Branch 10 (28→29) taken 7 times.
✓ Branch 12 (29→30) taken 7 times.
✓ Branch 14 (30→31) taken 7 times.
|
21 | std::cout << "\tvalue = '" << (*it)->getValue() << "', reference = '"<< *itRef << "', isOk = " << b << std::endl; |
| 50 | ++it; | ||
| 51 | ++itRef; | ||
| 52 | } | ||
| 53 | // std::cout << "checkKeyMapVecValue : b = " << b << std::endl; | ||
| 54 | 2 | return b; | |
| 55 | } | ||
| 56 | |||
| 57 | ///Call the check value with NULL pointers | ||
| 58 | 1 | void testCheckValue(){ | |
| 59 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | checkKeyMapValue(NULL, ""); |
| 60 | 1 | PVecString vecNoValue; | |
| 61 |
1/1✓ Branch 0 (6→7) taken 1 times.
|
1 | checkKeyMapVecValue(NULL, vecNoValue); |
| 62 | 1 | } | |
| 63 | |||
| 64 | ///Check the YML parser | ||
| 65 | 1 | void checkParserToml(){ | |
| 66 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[package]\nname = \"hello_hdf5\"\ndescription = \"some string in double quotes\"\nenable_option = true\ndisable_option = false\n\n"); |
| 67 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | ConfigNode dicoStr; |
| 68 |
5/5✓ Branch 0 (6→7) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
✓ Branch 6 (13→14) taken 1 times.
✓ Branch 8 (14→15) taken 1 times.
|
5 | phoenix_assert(parser_tomlString(dicoStr, fileContent)); |
| 69 |
2/2✓ Branch 0 (21→22) taken 1 times.
✓ Branch 2 (22→23) taken 1 times.
|
1 | PPath tomlFile("test.toml"); |
| 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(tomlFile.saveFileContent(fileContent)); |
| 71 | |||
| 72 |
1/1✓ Branch 0 (41→42) taken 1 times.
|
1 | ConfigNode dico; |
| 73 |
5/5✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (47→48) taken 1 times.
✓ Branch 4 (50→51) taken 1 times.
✓ Branch 6 (51→52) taken 1 times.
✓ Branch 8 (52→53) taken 1 times.
|
5 | phoenix_assert(parser_toml(dico, tomlFile)); |
| 74 | // std::cout << "checkParserToml : output ConfigNode :" << std::endl; | ||
| 75 | // dico.print(); | ||
| 76 | |||
| 77 |
2/2✓ Branch 0 (59→60) taken 1 times.
✓ Branch 2 (60→61) taken 1 times.
|
1 | ConfigNode * mapPackage = dico.getChild("package"); |
| 78 | // bool isKeyExist = mapPackage != NULL; | ||
| 79 | // std::cout << "checkParserToml : isKeyExist = " << isKeyExist << std::endl; | ||
| 80 |
2/2✓ Branch 0 (62→63) taken 1 times.
✓ Branch 2 (63→64) taken 1 times.
|
1 | ConfigNode * mapPackageName = mapPackage->getChild("name"); |
| 81 |
6/6✓ Branch 0 (67→68) taken 1 times.
✓ Branch 2 (70→71) taken 1 times.
✓ Branch 4 (73→74) taken 1 times.
✓ Branch 6 (74→75) taken 1 times.
✓ Branch 8 (75→76) taken 1 times.
✓ Branch 10 (76→77) taken 1 times.
|
6 | phoenix_assert(checkKeyMapValue(mapPackageName, "\"hello_hdf5\"")); |
| 82 | |||
| 83 |
9/9✓ Branch 0 (86→87) taken 1 times.
✓ Branch 2 (89→90) taken 1 times.
✓ Branch 4 (92→93) taken 1 times.
✓ Branch 6 (93→94) taken 1 times.
✓ Branch 8 (94→95) taken 1 times.
✓ Branch 10 (95→96) taken 1 times.
✓ Branch 12 (96→97) taken 1 times.
✓ Branch 14 (97→98) taken 1 times.
✓ Branch 16 (98→99) taken 1 times.
|
6 | phoenix_assert(phoenix_get_string(*mapPackage, "name", "SomeVar", "") == "hello_hdf5"); |
| 84 |
9/9✓ Branch 0 (111→112) taken 1 times.
✓ Branch 2 (114→115) taken 1 times.
✓ Branch 4 (117→118) taken 1 times.
✓ Branch 6 (118→119) taken 1 times.
✓ Branch 8 (119→120) taken 1 times.
✓ Branch 10 (120→121) taken 1 times.
✓ Branch 12 (121→122) taken 1 times.
✓ Branch 14 (122→123) taken 1 times.
✓ Branch 16 (123→124) taken 1 times.
|
6 | phoenix_assert(phoenix_get_string(*mapPackage, "undefined_var", "SomeVar", "") == "SomeVar"); |
| 85 |
9/9✓ Branch 0 (136→137) taken 1 times.
✓ Branch 2 (139→140) taken 1 times.
✓ Branch 4 (142→143) taken 1 times.
✓ Branch 6 (143→144) taken 1 times.
✓ Branch 8 (144→145) taken 1 times.
✓ Branch 10 (145→146) taken 1 times.
✓ Branch 12 (146→147) taken 1 times.
✓ Branch 14 (147→148) taken 1 times.
✓ Branch 16 (148→149) taken 1 times.
|
6 | phoenix_assert(phoenix_get_string(*mapPackage, "undefined_var", "", "SomeVar") == "SomeVar"); |
| 86 |
8/8✓ Branch 0 (161→162) taken 1 times.
✓ Branch 2 (164→165) taken 1 times.
✓ Branch 4 (167→168) taken 1 times.
✓ Branch 6 (168→169) taken 1 times.
✓ Branch 8 (169→170) taken 1 times.
✓ Branch 10 (170→171) taken 1 times.
✓ Branch 12 (171→172) taken 1 times.
✓ Branch 14 (172→173) taken 1 times.
|
5 | phoenix_assert(phoenix_get_string(*mapPackage, "undefined_var", "SomeVar") == "SomeVar"); |
| 87 | |||
| 88 |
2/2✓ Branch 0 (182→183) taken 1 times.
✓ Branch 2 (183→184) taken 1 times.
|
1 | ConfigNode * mapPackageEnableOption = mapPackage->getChild("enable_option"); |
| 89 |
6/6✓ Branch 0 (187→188) taken 1 times.
✓ Branch 2 (190→191) taken 1 times.
✓ Branch 4 (193→194) taken 1 times.
✓ Branch 6 (194→195) taken 1 times.
✓ Branch 8 (195→196) taken 1 times.
✓ Branch 10 (196→197) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapPackageEnableOption, "true")); |
| 90 | |||
| 91 |
2/2✓ Branch 0 (204→205) taken 1 times.
✓ Branch 2 (205→206) taken 1 times.
|
1 | ConfigNode * mapPackageDisableOption = mapPackage->getChild("disable_option"); |
| 92 |
6/6✓ Branch 0 (209→210) taken 1 times.
✓ Branch 2 (212→213) taken 1 times.
✓ Branch 4 (215→216) taken 1 times.
✓ Branch 6 (216→217) taken 1 times.
✓ Branch 8 (217→218) taken 1 times.
✓ Branch 10 (218→219) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapPackageDisableOption, "false")); |
| 93 | 1 | } | |
| 94 | |||
| 95 | ///Check the embeded dico | ||
| 96 | 1 | void checkTomlList(){ | |
| 97 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[package]\nname = \"hello_hdf5\"\ndescription = 'some string in simple quotes'\nsome_list = [\"one\", \"two\", \"three\"]\nlist_value = [1, 2, 3, 4]\n\n[dependencies]\nhdf5 = \"0.8.1\"\nndarray = '0.15.6'\n\n"); |
| 98 | |||
| 99 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_list.toml"); |
| 100 |
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(tomlFile.saveFileContent(fileContent)); |
| 101 | |||
| 102 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 103 |
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_toml(dico, tomlFile)); |
| 104 | // std::cout << "checkTomlList : output ConfigNode :" << std::endl; | ||
| 105 | // dico.print(); | ||
| 106 | |||
| 107 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapPackage = dico.getChild("package"); |
| 108 | // bool isKeyExist = mapPackage != NULL; | ||
| 109 | // std::cout << "checkTomlList : isKeyExist = " << isKeyExist << std::endl; | ||
| 110 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | ConfigNode * mapPackageName = mapPackage->getChild("name"); |
| 111 |
6/6✓ Branch 0 (49→50) taken 1 times.
✓ Branch 2 (52→53) taken 1 times.
✓ Branch 4 (55→56) taken 1 times.
✓ Branch 6 (56→57) taken 1 times.
✓ Branch 8 (57→58) taken 1 times.
✓ Branch 10 (58→59) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapPackageName, "\"hello_hdf5\"")); |
| 112 |
2/2✓ Branch 0 (66→67) taken 1 times.
✓ Branch 2 (67→68) taken 1 times.
|
1 | ConfigNode * mapPackageDescription = mapPackage->getChild("description"); |
| 113 |
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 (78→79) taken 1 times.
✓ Branch 8 (79→80) taken 1 times.
✓ Branch 10 (80→81) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapPackageDescription, "'some string in simple quotes'")); |
| 114 | |||
| 115 |
2/2✓ Branch 0 (88→89) taken 1 times.
✓ Branch 2 (89→90) taken 1 times.
|
1 | ConfigNode * mapSomeListKey = mapPackage->getChild("some_list"); |
| 116 | // bool isSomeListExist = mapSomeListKey != NULL; | ||
| 117 | // std::cout << "checkTomlList : isSomeListExist = " << isSomeListExist << std::endl; | ||
| 118 | |||
| 119 | 1 | PVecString vecExpectedValue; | |
| 120 |
2/2✓ Branch 0 (92→93) taken 1 times.
✓ Branch 2 (93→94) taken 1 times.
|
1 | vecExpectedValue.push_back("\"one\""); |
| 121 |
2/2✓ Branch 0 (95→96) taken 1 times.
✓ Branch 2 (96→97) taken 1 times.
|
1 | vecExpectedValue.push_back("\"two\""); |
| 122 |
2/2✓ Branch 0 (98→99) taken 1 times.
✓ Branch 2 (99→100) taken 1 times.
|
1 | vecExpectedValue.push_back("\"three\""); |
| 123 |
5/5✓ Branch 0 (103→104) taken 1 times.
✓ Branch 2 (106→107) taken 1 times.
✓ Branch 4 (109→110) taken 1 times.
✓ Branch 6 (110→111) taken 1 times.
✓ Branch 8 (111→112) taken 1 times.
|
5 | phoenix_assert(checkKeyMapVecValue(mapSomeListKey, vecExpectedValue)); |
| 124 | |||
| 125 |
2/2✓ Branch 0 (118→119) taken 1 times.
✓ Branch 2 (119→120) taken 1 times.
|
1 | ConfigNode * mapOtherListKey = mapPackage->getChild("list_value"); |
| 126 | // bool isOtherListExist = mapOtherListKey != NULL; | ||
| 127 | // std::cout << "checkTomlList : isOtherListExist = " << isOtherListExist << std::endl; | ||
| 128 | |||
| 129 | 1 | PVecString vecOtherExpectedValue; | |
| 130 |
2/2✓ Branch 0 (122→123) taken 1 times.
✓ Branch 2 (123→124) taken 1 times.
|
1 | vecOtherExpectedValue.push_back("1"); |
| 131 |
2/2✓ Branch 0 (125→126) taken 1 times.
✓ Branch 2 (126→127) taken 1 times.
|
1 | vecOtherExpectedValue.push_back("2"); |
| 132 |
2/2✓ Branch 0 (128→129) taken 1 times.
✓ Branch 2 (129→130) taken 1 times.
|
1 | vecOtherExpectedValue.push_back("3"); |
| 133 |
2/2✓ Branch 0 (131→132) taken 1 times.
✓ Branch 2 (132→133) taken 1 times.
|
1 | vecOtherExpectedValue.push_back("4"); |
| 134 |
5/5✓ Branch 0 (136→137) taken 1 times.
✓ Branch 2 (139→140) taken 1 times.
✓ Branch 4 (142→143) taken 1 times.
✓ Branch 6 (143→144) taken 1 times.
✓ Branch 8 (144→145) taken 1 times.
|
5 | phoenix_assert(checkKeyMapVecValue(mapOtherListKey, vecOtherExpectedValue)); |
| 135 | |||
| 136 |
2/2✓ Branch 0 (151→152) taken 1 times.
✓ Branch 2 (152→153) taken 1 times.
|
1 | ConfigNode * mapDependencies = dico.getChild("dependencies"); |
| 137 |
2/2✓ Branch 0 (154→155) taken 1 times.
✓ Branch 2 (155→156) taken 1 times.
|
1 | ConfigNode * mapDependenciesHdf5 = mapDependencies->getChild("hdf5"); |
| 138 |
6/6✓ Branch 0 (159→160) taken 1 times.
✓ Branch 2 (162→163) taken 1 times.
✓ Branch 4 (165→166) taken 1 times.
✓ Branch 6 (166→167) taken 1 times.
✓ Branch 8 (167→168) taken 1 times.
✓ Branch 10 (168→169) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapDependenciesHdf5, "\"0.8.1\"")); |
| 139 |
2/2✓ Branch 0 (176→177) taken 1 times.
✓ Branch 2 (177→178) taken 1 times.
|
1 | ConfigNode * mapDependenciesNdarray = mapDependencies->getChild("ndarray"); |
| 140 |
6/6✓ Branch 0 (181→182) taken 1 times.
✓ Branch 2 (184→185) taken 1 times.
✓ Branch 4 (187→188) taken 1 times.
✓ Branch 6 (188→189) taken 1 times.
✓ Branch 8 (189→190) taken 1 times.
✓ Branch 10 (190→191) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapDependenciesNdarray, "'0.15.6'")); |
| 141 | 1 | } | |
| 142 | |||
| 143 | ///Check the embeded dico | ||
| 144 | 1 | void checkTomlEmptyList(){ | |
| 145 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[package]\nsome_list = []\n\n"); |
| 146 | |||
| 147 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_empty_list.toml"); |
| 148 |
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(tomlFile.saveFileContent(fileContent)); |
| 149 | |||
| 150 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 151 |
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_toml(dico, tomlFile)); |
| 152 | // std::cout << "checkTomlEmptyList : output ConfigNode :" << std::endl; | ||
| 153 | // dico.print(); | ||
| 154 | |||
| 155 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapPackage = dico.getChild("package"); |
| 156 | // bool isKeyExist = mapPackage != NULL; | ||
| 157 | // std::cout << "checkTomlEmptyList : isKeyExist = " << isKeyExist << std::endl; | ||
| 158 | |||
| 159 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | ConfigNode * mapSomeListKey = mapPackage->getChild("some_list"); |
| 160 | // bool isSomeListExist = mapSomeListKey != NULL; | ||
| 161 | // std::cout << "checkTomlEmptyList : isSomeListExist = " << isSomeListExist << std::endl; | ||
| 162 |
5/5✓ Branch 0 (49→50) taken 1 times.
✓ Branch 2 (52→53) taken 1 times.
✓ Branch 4 (55→56) taken 1 times.
✓ Branch 6 (56→57) taken 1 times.
✓ Branch 8 (58→59) taken 1 times.
|
5 | phoenix_assert(mapSomeListKey->getVecChild().size() == 0lu); |
| 163 | 1 | } | |
| 164 | |||
| 165 | |||
| 166 | ///Check the embeded dico | ||
| 167 | 1 | void checkTomNestedlList(){ | |
| 168 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[package]\nsome_nested_list = [1, 2, [3, 4]]\n\n"); |
| 169 | |||
| 170 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_nested_list.toml"); |
| 171 |
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(tomlFile.saveFileContent(fileContent)); |
| 172 | |||
| 173 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 174 |
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_toml(dico, tomlFile)); |
| 175 | // std::cout << "checkTomlNestedList : output ConfigNode :" << std::endl; | ||
| 176 | // dico.print(); | ||
| 177 | |||
| 178 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapPackage = dico.getChild("package"); |
| 179 | // bool isKeyExist = mapPackage != NULL; | ||
| 180 | // std::cout << "checkTomlNestedList : isKeyExist = " << isKeyExist << std::endl; | ||
| 181 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | ConfigNode * mapOtherListKey = mapPackage->getChild("some_nested_list"); |
| 182 | // bool isOtherListExist = mapOtherListKey != NULL; | ||
| 183 | // std::cout << "checkTomlNestedList : isOtherListExist = " << isOtherListExist << std::endl; | ||
| 184 | |||
| 185 |
1/1✓ Branch 0 (47→48) taken 1 times.
|
1 | const VecConfigNode & vecValue = mapOtherListKey->getVecChild(); |
| 186 |
4/4✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (56→57) taken 1 times.
✓ Branch 6 (58→59) taken 1 times.
|
6 | phoenix_assert(vecValue.size() == 3lu); |
| 187 |
6/6✓ Branch 0 (67→68) taken 1 times.
✓ Branch 2 (70→71) taken 1 times.
✓ Branch 4 (73→74) taken 1 times.
✓ Branch 6 (75→76) taken 1 times.
✓ Branch 8 (76→77) taken 1 times.
✓ Branch 10 (77→78) taken 1 times.
|
6 | phoenix_assert(vecValue[0]->getValue() == "1"); |
| 188 |
6/6✓ Branch 0 (86→87) taken 1 times.
✓ Branch 2 (89→90) taken 1 times.
✓ Branch 4 (92→93) taken 1 times.
✓ Branch 6 (94→95) taken 1 times.
✓ Branch 8 (95→96) taken 1 times.
✓ Branch 10 (96→97) taken 1 times.
|
5 | phoenix_assert(vecValue[1]->getValue() == "2"); |
| 189 | |||
| 190 | 1 | const ConfigNode * subList = vecValue[2]; | |
| 191 |
1/1✓ Branch 0 (104→105) taken 1 times.
|
1 | const VecConfigNode & vecSubValue = subList->getVecChild(); |
| 192 |
4/4✓ Branch 0 (107→108) taken 1 times.
✓ Branch 2 (110→111) taken 1 times.
✓ Branch 4 (113→114) taken 1 times.
✓ Branch 6 (115→116) taken 1 times.
|
6 | phoenix_assert(vecSubValue.size() == 2lu); |
| 193 |
6/6✓ Branch 0 (124→125) taken 1 times.
✓ Branch 2 (127→128) taken 1 times.
✓ Branch 4 (130→131) taken 1 times.
✓ Branch 6 (132→133) taken 1 times.
✓ Branch 8 (133→134) taken 1 times.
✓ Branch 10 (134→135) taken 1 times.
|
6 | phoenix_assert(vecSubValue[0]->getValue() == "3"); |
| 194 |
6/6✓ Branch 0 (143→144) taken 1 times.
✓ Branch 2 (146→147) taken 1 times.
✓ Branch 4 (149→150) taken 1 times.
✓ Branch 6 (151→152) taken 1 times.
✓ Branch 8 (152→153) taken 1 times.
✓ Branch 10 (153→154) taken 1 times.
|
5 | phoenix_assert(vecSubValue[1]->getValue() == "4"); |
| 195 | 1 | } | |
| 196 | |||
| 197 | |||
| 198 | ///Check the embeded dico | ||
| 199 | 1 | void checkTomNestedlMap(){ | |
| 200 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[first.second]\nsome_value = 42\n\n"); |
| 201 | |||
| 202 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_nested_map.toml"); |
| 203 |
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(tomlFile.saveFileContent(fileContent)); |
| 204 | |||
| 205 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 206 |
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_toml(dico, tomlFile)); |
| 207 | // std::cout << "checkTomNestedlMap : output ConfigNode :" << std::endl; | ||
| 208 | // dico.print(); | ||
| 209 | |||
| 210 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapFirst = dico.getChild("first"); |
| 211 | // bool isKeyExist = mapFirst != NULL; | ||
| 212 | // std::cout << "checkTomNestedlMap : isKeyExist = " << isKeyExist << std::endl; | ||
| 213 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | ConfigNode * mapSecond = mapFirst->getChild("second"); |
| 214 |
2/2✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (48→49) taken 1 times.
|
1 | ConfigNode * mapOtherListKey = mapSecond->getChild("some_value"); |
| 215 |
6/6✓ Branch 0 (52→53) taken 1 times.
✓ Branch 2 (55→56) taken 1 times.
✓ Branch 4 (58→59) taken 1 times.
✓ Branch 6 (59→60) taken 1 times.
✓ Branch 8 (60→61) taken 1 times.
✓ Branch 10 (61→62) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapOtherListKey, "42")); |
| 216 | 1 | } | |
| 217 | |||
| 218 | ///Check the embeded dico | ||
| 219 | 1 | void checkTomTable(){ | |
| 220 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[[program]]\nname = \"shadok\"\nage = 42\n\n[[program]]\nname = \"gibi\"\nage = 23\n\n"); |
| 221 | |||
| 222 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_table.toml"); |
| 223 |
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(tomlFile.saveFileContent(fileContent)); |
| 224 | |||
| 225 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 226 |
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_toml(dico, tomlFile)); |
| 227 | // std::cout << "checkTomTable : output ConfigNode :" << std::endl; | ||
| 228 | // dico.print(); | ||
| 229 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapProgram = dico.getChild("program"); |
| 230 | // bool isKeyExist = mapProgram != NULL; | ||
| 231 | // std::cout << "checkTomTable : isKeyExist = " << isKeyExist << std::endl; | ||
| 232 |
1/1✓ Branch 0 (44→45) taken 1 times.
|
1 | const VecConfigNode & vecProgramValue = mapProgram->getVecChild(); |
| 233 |
4/4✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (50→51) taken 1 times.
✓ Branch 4 (53→54) taken 1 times.
✓ Branch 6 (55→56) taken 1 times.
|
5 | phoenix_assert(vecProgramValue.size() == 2lu); |
| 234 |
2/2✓ Branch 0 (63→64) taken 1 times.
✓ Branch 2 (64→65) taken 1 times.
|
1 | const ConfigNode * mapProgram0Name = vecProgramValue[0]->getChild("name"); |
| 235 |
6/6✓ Branch 0 (68→69) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
✓ Branch 4 (74→75) taken 1 times.
✓ Branch 6 (75→76) taken 1 times.
✓ Branch 8 (76→77) taken 1 times.
✓ Branch 10 (77→78) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapProgram0Name, "\"shadok\"")); |
| 236 |
2/2✓ Branch 0 (86→87) taken 1 times.
✓ Branch 2 (87→88) taken 1 times.
|
1 | const ConfigNode * mapProgram0Age = vecProgramValue[0]->getChild("age"); |
| 237 |
6/6✓ Branch 0 (91→92) taken 1 times.
✓ Branch 2 (94→95) taken 1 times.
✓ Branch 4 (97→98) taken 1 times.
✓ Branch 6 (98→99) taken 1 times.
✓ Branch 8 (99→100) taken 1 times.
✓ Branch 10 (100→101) taken 1 times.
|
6 | phoenix_assert(checkKeyMapValue(mapProgram0Age, "42")); |
| 238 | |||
| 239 |
8/8✓ 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.
✓ Branch 8 (118→119) taken 1 times.
✓ Branch 10 (121→122) taken 1 times.
✓ Branch 12 (122→123) taken 1 times.
✓ Branch 14 (123→124) taken 1 times.
|
7 | phoenix_assert(phoenix_check("checkTomTable : location", mapProgram0Name->getLocation(), PLocation(tomlFile, 2, 6))); |
| 240 | |||
| 241 |
2/2✓ Branch 0 (135→136) taken 1 times.
✓ Branch 2 (136→137) taken 1 times.
|
1 | const ConfigNode * mapProgram1Name = vecProgramValue[1]->getChild("name"); |
| 242 |
6/6✓ Branch 0 (140→141) taken 1 times.
✓ Branch 2 (143→144) taken 1 times.
✓ Branch 4 (146→147) taken 1 times.
✓ Branch 6 (147→148) taken 1 times.
✓ Branch 8 (148→149) taken 1 times.
✓ Branch 10 (149→150) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapProgram1Name, "\"gibi\"")); |
| 243 |
2/2✓ Branch 0 (158→159) taken 1 times.
✓ Branch 2 (159→160) taken 1 times.
|
1 | const ConfigNode * mapProgram1Age = vecProgramValue[1]->getChild("age"); |
| 244 |
6/6✓ Branch 0 (163→164) taken 1 times.
✓ Branch 2 (166→167) taken 1 times.
✓ Branch 4 (169→170) taken 1 times.
✓ Branch 6 (170→171) taken 1 times.
✓ Branch 8 (171→172) taken 1 times.
✓ Branch 10 (172→173) taken 1 times.
|
6 | phoenix_assert(checkKeyMapValue(mapProgram1Age, "23")); |
| 245 | |||
| 246 |
8/8✓ Branch 0 (182→183) taken 1 times.
✓ Branch 2 (185→186) taken 1 times.
✓ Branch 4 (188→189) taken 1 times.
✓ Branch 6 (189→190) taken 1 times.
✓ Branch 8 (190→191) taken 1 times.
✓ Branch 10 (193→194) taken 1 times.
✓ Branch 12 (194→195) taken 1 times.
✓ Branch 14 (195→196) taken 1 times.
|
7 | phoenix_assert(phoenix_check("checkTomTable : location", mapProgram1Name->getLocation(), PLocation(tomlFile, 6, 6))); |
| 247 | 1 | } | |
| 248 | |||
| 249 | ///Check the compact dico | ||
| 250 | 1 | void checkTomlCompactDico(){ | |
| 251 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[program]\nname = {url = \"someUrl\"}\nage = 42\n\n"); |
| 252 | |||
| 253 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_compact_dico.toml"); |
| 254 |
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(tomlFile.saveFileContent(fileContent)); |
| 255 | |||
| 256 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 257 |
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_toml(dico, tomlFile)); |
| 258 | // std::cout << "checkTomlCompactDico : output ConfigNode :" << std::endl; | ||
| 259 | // dico.print(); | ||
| 260 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapProgram = dico.getChild("program"); |
| 261 | // bool isKeyExist = mapProgram != NULL; | ||
| 262 | // std::cout << "checkTomlCompactDico : isKeyExist = " << isKeyExist << std::endl; | ||
| 263 |
2/2✓ Branch 0 (44→45) taken 1 times.
✓ Branch 2 (45→46) taken 1 times.
|
1 | const ConfigNode * mapName = mapProgram->getChild("name"); |
| 264 |
2/2✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (48→49) taken 1 times.
|
1 | const ConfigNode * mapNameUrl = mapName->getChild("url"); |
| 265 |
6/6✓ Branch 0 (52→53) taken 1 times.
✓ Branch 2 (55→56) taken 1 times.
✓ Branch 4 (58→59) taken 1 times.
✓ Branch 6 (59→60) taken 1 times.
✓ Branch 8 (60→61) taken 1 times.
✓ Branch 10 (61→62) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapNameUrl, "\"someUrl\"")); |
| 266 |
2/2✓ Branch 0 (69→70) taken 1 times.
✓ Branch 2 (70→71) taken 1 times.
|
1 | const ConfigNode * mapAge = mapProgram->getChild("age"); |
| 267 |
6/6✓ Branch 0 (74→75) taken 1 times.
✓ Branch 2 (77→78) taken 1 times.
✓ Branch 4 (80→81) taken 1 times.
✓ Branch 6 (81→82) taken 1 times.
✓ Branch 8 (82→83) taken 1 times.
✓ Branch 10 (83→84) taken 1 times.
|
6 | phoenix_assert(checkKeyMapValue(mapAge, "42")); |
| 268 | |||
| 269 |
8/8✓ Branch 0 (93→94) taken 1 times.
✓ Branch 2 (96→97) taken 1 times.
✓ Branch 4 (99→100) taken 1 times.
✓ Branch 6 (100→101) taken 1 times.
✓ Branch 8 (101→102) taken 1 times.
✓ Branch 10 (104→105) taken 1 times.
✓ Branch 12 (105→106) taken 1 times.
✓ Branch 14 (106→107) taken 1 times.
|
7 | phoenix_assert(phoenix_check("checkTomlCompactDico : location", mapNameUrl->getLocation(), PLocation(tomlFile, 2, 13))); |
| 270 | 1 | } | |
| 271 | |||
| 272 | ///Check the compact dico | ||
| 273 | 1 | void checkTomlCompactDico2(){ | |
| 274 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[program]\nname = {url = \"someUrl\",\n#Some comment\n version = \"1.0.0\"}\n# Some Comment\nage = 42\nemptyDico = {}\n\n"); |
| 275 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_compact_dico.toml"); |
| 276 |
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(tomlFile.saveFileContent(fileContent)); |
| 277 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 278 |
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_toml(dico, tomlFile)); |
| 279 | // std::cout << "checkTomlCompactDico : output ConfigNode :" << std::endl; | ||
| 280 | // dico.print(); | ||
| 281 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapProgram = dico.getChild("program"); |
| 282 |
8/8✓ Branch 0 (46→47) taken 1 times.
✓ Branch 2 (49→50) taken 1 times.
✓ Branch 4 (52→53) taken 1 times.
✓ Branch 6 (53→54) taken 1 times.
✓ Branch 8 (54→55) taken 1 times.
✓ Branch 10 (57→58) taken 1 times.
✓ Branch 12 (58→59) taken 1 times.
✓ Branch 14 (59→60) taken 1 times.
|
7 | phoenix_assert(phoenix_check("checkTomlCompactDico : location", mapProgram->getLocation(), PLocation(tomlFile, 1, 9))); |
| 283 | // bool isKeyExist = mapProgram != NULL; | ||
| 284 | // std::cout << "checkTomlCompactDico : isKeyExist = " << isKeyExist << std::endl; | ||
| 285 |
2/2✓ Branch 0 (70→71) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
|
1 | const ConfigNode * mapName = mapProgram->getChild("name"); |
| 286 |
2/2✓ Branch 0 (73→74) taken 1 times.
✓ Branch 2 (74→75) taken 1 times.
|
1 | const ConfigNode * mapNameUrl = mapName->getChild("url"); |
| 287 |
6/6✓ Branch 0 (78→79) taken 1 times.
✓ Branch 2 (81→82) taken 1 times.
✓ Branch 4 (84→85) taken 1 times.
✓ Branch 6 (85→86) taken 1 times.
✓ Branch 8 (86→87) taken 1 times.
✓ Branch 10 (87→88) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapNameUrl, "\"someUrl\"")); |
| 288 |
2/2✓ Branch 0 (95→96) taken 1 times.
✓ Branch 2 (96→97) taken 1 times.
|
1 | const ConfigNode * mapNameVersion = mapName->getChild("version"); |
| 289 |
6/6✓ Branch 0 (100→101) taken 1 times.
✓ Branch 2 (103→104) taken 1 times.
✓ Branch 4 (106→107) taken 1 times.
✓ Branch 6 (107→108) taken 1 times.
✓ Branch 8 (108→109) taken 1 times.
✓ Branch 10 (109→110) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapNameVersion, "\"1.0.0\"")); |
| 290 |
2/2✓ Branch 0 (117→118) taken 1 times.
✓ Branch 2 (118→119) taken 1 times.
|
1 | const ConfigNode * mapAge = mapProgram->getChild("age"); |
| 291 |
6/6✓ Branch 0 (122→123) taken 1 times.
✓ Branch 2 (125→126) taken 1 times.
✓ Branch 4 (128→129) taken 1 times.
✓ Branch 6 (129→130) taken 1 times.
✓ Branch 8 (130→131) taken 1 times.
✓ Branch 10 (131→132) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(mapAge, "42")); |
| 292 | 1 | } | |
| 293 | |||
| 294 | ///Check if the parsing of a file is OK | ||
| 295 | /** @param fileName : name of the file to be created | ||
| 296 | * @param fileContent : content of the file | ||
| 297 | * @return true on success, false otherwise | ||
| 298 | */ | ||
| 299 | 9 | bool checkIsParserOk(const PPath & fileName, const PString & fileContent){ | |
| 300 | 9 | bool b(true); | |
| 301 |
1/1✓ Branch 0 (2→3) taken 9 times.
|
9 | b &= fileName.saveFileContent(fileContent); |
| 302 |
1/1✓ Branch 0 (3→4) taken 9 times.
|
9 | ConfigNode dico; |
| 303 |
1/1✓ Branch 0 (4→5) taken 9 times.
|
9 | b &= parser_toml(dico, fileName); |
| 304 | 9 | return b; | |
| 305 | 9 | } | |
| 306 | |||
| 307 | ///Check the YML parser | ||
| 308 | 1 | void checkParserTomlFail(){ | |
| 309 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | ConfigNode dico; |
| 310 |
7/7✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (11→12) taken 1 times.
✓ Branch 6 (12→13) taken 1 times.
✓ Branch 8 (13→14) taken 1 times.
✓ Branch 10 (14→15) taken 1 times.
✓ Branch 12 (15→16) taken 1 times.
|
6 | phoenix_assert(!parser_toml(dico, PString("UnexsitingFileName.toml"))); |
| 311 |
8/8✓ 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.
✓ Branch 10 (35→36) taken 1 times.
✓ Branch 12 (36→37) taken 1 times.
✓ Branch 14 (37→38) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("unextected_token.toml"), "=\n")); |
| 312 |
8/8✓ Branch 0 (49→50) taken 1 times.
✓ Branch 2 (52→53) taken 1 times.
✓ Branch 4 (55→56) taken 1 times.
✓ Branch 6 (56→57) taken 1 times.
✓ Branch 8 (57→58) taken 1 times.
✓ Branch 10 (58→59) taken 1 times.
✓ Branch 12 (59→60) taken 1 times.
✓ Branch 14 (60→61) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("missing_equal_of_variable.toml"), "[package]\nvariable value\n")); |
| 313 |
8/8✓ Branch 0 (72→73) taken 1 times.
✓ Branch 2 (75→76) taken 1 times.
✓ Branch 4 (78→79) taken 1 times.
✓ Branch 6 (79→80) taken 1 times.
✓ Branch 8 (80→81) taken 1 times.
✓ Branch 10 (81→82) taken 1 times.
✓ Branch 12 (82→83) taken 1 times.
✓ Branch 14 (83→84) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("missing_value_of_variable.toml"), "[package]\nvariable =\n")); |
| 314 |
8/8✓ Branch 0 (95→96) taken 1 times.
✓ Branch 2 (98→99) taken 1 times.
✓ Branch 4 (101→102) taken 1 times.
✓ Branch 6 (102→103) taken 1 times.
✓ Branch 8 (103→104) taken 1 times.
✓ Branch 10 (104→105) taken 1 times.
✓ Branch 12 (105→106) taken 1 times.
✓ Branch 14 (106→107) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("unclosed_list.toml"), "[package]\nlist = [42\n")); |
| 315 |
8/8✓ Branch 0 (118→119) taken 1 times.
✓ Branch 2 (121→122) taken 1 times.
✓ Branch 4 (124→125) taken 1 times.
✓ Branch 6 (125→126) taken 1 times.
✓ Branch 8 (126→127) taken 1 times.
✓ Branch 10 (127→128) taken 1 times.
✓ Branch 12 (128→129) taken 1 times.
✓ Branch 14 (129→130) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("unclosed_empty_list.toml"), "[package]\nlist = [\n")); |
| 316 |
8/8✓ Branch 0 (141→142) taken 1 times.
✓ Branch 2 (144→145) taken 1 times.
✓ Branch 4 (147→148) taken 1 times.
✓ Branch 6 (148→149) taken 1 times.
✓ Branch 8 (149→150) taken 1 times.
✓ Branch 10 (150→151) taken 1 times.
✓ Branch 12 (151→152) taken 1 times.
✓ Branch 14 (152→153) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("unclosed_dico.toml"), "[package]\ndico = {name\n")); |
| 317 |
8/8✓ Branch 0 (164→165) taken 1 times.
✓ Branch 2 (167→168) taken 1 times.
✓ Branch 4 (170→171) taken 1 times.
✓ Branch 6 (171→172) taken 1 times.
✓ Branch 8 (172→173) taken 1 times.
✓ Branch 10 (173→174) taken 1 times.
✓ Branch 12 (174→175) taken 1 times.
✓ Branch 14 (175→176) taken 1 times.
|
6 | phoenix_assert(!checkIsParserOk(PString("unclosed_empty_dico.toml"), "[package]\ndico = {\n")); |
| 318 |
8/8✓ Branch 0 (187→188) taken 1 times.
✓ Branch 2 (190→191) taken 1 times.
✓ Branch 4 (193→194) taken 1 times.
✓ Branch 6 (194→195) taken 1 times.
✓ Branch 8 (195→196) taken 1 times.
✓ Branch 10 (196→197) taken 1 times.
✓ Branch 12 (197→198) taken 1 times.
✓ Branch 14 (198→199) taken 1 times.
|
6 | phoenix_assert(checkIsParserOk(PString("some_comment.toml"), "# Some value\n[package]\nvalue = 42\n")); |
| 319 |
8/8✓ Branch 0 (210→211) taken 1 times.
✓ Branch 2 (213→214) taken 1 times.
✓ Branch 4 (216→217) taken 1 times.
✓ Branch 6 (217→218) taken 1 times.
✓ Branch 8 (218→219) taken 1 times.
✓ Branch 10 (219→220) taken 1 times.
✓ Branch 12 (220→221) taken 1 times.
✓ Branch 14 (221→222) taken 1 times.
|
5 | phoenix_assert(checkIsParserOk(PString("some_triple_double_quote_string.toml"), "# Some value\n[package]\nstrvalue = \"\"\"\nsome string\n\"\"\"\n")); |
| 320 | 1 | } | |
| 321 | |||
| 322 | ///Check the compact dico with complex nested structures using ConfigNode | ||
| 323 | 1 | void checkListOfDico(){ | |
| 324 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString fileContent("[project]\nauthors = [\n { firstName = \"Oprinsen\", lastName = \"Thibaut\", mail = \"thibaut.oprinsen@lapp.in2p3.fr\" },\n { firstName = \"Aubert\", lastName = \"Pierre\", mail = \"pierre.aubert@lapp.in2p3.fr\" }\n]\nmaintainers = [\n { firstName = \"Aubert\", lastName = \"Pierre\", mail = \"pierre.aubert@lapp.in2p3.fr\" }\n]\n\n"); |
| 325 | |||
| 326 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
|
1 | PPath tomlFile("test_toml_complex_compact_dico.toml"); |
| 327 |
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(tomlFile.saveFileContent(fileContent)); |
| 328 | |||
| 329 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | ConfigNode dico; |
| 330 |
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_toml(dico, tomlFile)); |
| 331 | |||
| 332 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | ConfigNode * mapProject = dico.getChild("project"); |
| 333 |
4/4✓ Branch 0 (46→47) taken 1 times.
✓ Branch 2 (49→50) taken 1 times.
✓ Branch 4 (52→53) taken 1 times.
✓ Branch 6 (53→54) taken 1 times.
|
5 | phoenix_assert(mapProject != NULL); |
| 334 | |||
| 335 | // Test authors array with compact dictionaries | ||
| 336 |
2/2✓ Branch 0 (60→61) taken 1 times.
✓ Branch 2 (61→62) taken 1 times.
|
1 | ConfigNode * mapAuthors = mapProject->getChild("authors"); |
| 337 |
4/4✓ 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.
|
5 | phoenix_assert(mapAuthors != NULL); |
| 338 |
1/1✓ Branch 0 (79→80) taken 1 times.
|
1 | const VecConfigNode & vecAuthors = mapAuthors->getVecChild(); |
| 339 |
4/4✓ Branch 0 (82→83) taken 1 times.
✓ Branch 2 (85→86) taken 1 times.
✓ Branch 4 (88→89) taken 1 times.
✓ Branch 6 (90→91) taken 1 times.
|
5 | phoenix_assert(vecAuthors.size() == 2lu); |
| 340 | |||
| 341 | // Check first author | ||
| 342 |
2/2✓ Branch 0 (98→99) taken 1 times.
✓ Branch 2 (99→100) taken 1 times.
|
1 | const ConfigNode * author1FirstName = vecAuthors[0]->getChild("firstName"); |
| 343 |
6/6✓ Branch 0 (103→104) taken 1 times.
✓ Branch 2 (106→107) taken 1 times.
✓ Branch 4 (109→110) taken 1 times.
✓ Branch 6 (110→111) taken 1 times.
✓ Branch 8 (111→112) taken 1 times.
✓ Branch 10 (112→113) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author1FirstName, "\"Oprinsen\"")); |
| 344 |
2/2✓ Branch 0 (121→122) taken 1 times.
✓ Branch 2 (122→123) taken 1 times.
|
1 | const ConfigNode * author1LastName = vecAuthors[0]->getChild("lastName"); |
| 345 |
6/6✓ Branch 0 (126→127) taken 1 times.
✓ Branch 2 (129→130) taken 1 times.
✓ Branch 4 (132→133) taken 1 times.
✓ Branch 6 (133→134) taken 1 times.
✓ Branch 8 (134→135) taken 1 times.
✓ Branch 10 (135→136) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author1LastName, "\"Thibaut\"")); |
| 346 |
2/2✓ Branch 0 (144→145) taken 1 times.
✓ Branch 2 (145→146) taken 1 times.
|
1 | const ConfigNode * author1Mail = vecAuthors[0]->getChild("mail"); |
| 347 |
6/6✓ Branch 0 (149→150) taken 1 times.
✓ Branch 2 (152→153) taken 1 times.
✓ Branch 4 (155→156) taken 1 times.
✓ Branch 6 (156→157) taken 1 times.
✓ Branch 8 (157→158) taken 1 times.
✓ Branch 10 (158→159) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author1Mail, "\"thibaut.oprinsen@lapp.in2p3.fr\"")); |
| 348 | |||
| 349 | // Check second author | ||
| 350 |
2/2✓ Branch 0 (167→168) taken 1 times.
✓ Branch 2 (168→169) taken 1 times.
|
1 | const ConfigNode * author2FirstName = vecAuthors[1]->getChild("firstName"); |
| 351 |
6/6✓ Branch 0 (172→173) taken 1 times.
✓ Branch 2 (175→176) taken 1 times.
✓ Branch 4 (178→179) taken 1 times.
✓ Branch 6 (179→180) taken 1 times.
✓ Branch 8 (180→181) taken 1 times.
✓ Branch 10 (181→182) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author2FirstName, "\"Aubert\"")); |
| 352 |
2/2✓ Branch 0 (190→191) taken 1 times.
✓ Branch 2 (191→192) taken 1 times.
|
1 | const ConfigNode * author2LastName = vecAuthors[1]->getChild("lastName"); |
| 353 |
6/6✓ Branch 0 (195→196) taken 1 times.
✓ Branch 2 (198→199) taken 1 times.
✓ Branch 4 (201→202) taken 1 times.
✓ Branch 6 (202→203) taken 1 times.
✓ Branch 8 (203→204) taken 1 times.
✓ Branch 10 (204→205) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author2LastName, "\"Pierre\"")); |
| 354 |
2/2✓ Branch 0 (213→214) taken 1 times.
✓ Branch 2 (214→215) taken 1 times.
|
1 | const ConfigNode * author2Mail = vecAuthors[1]->getChild("mail"); |
| 355 |
6/6✓ Branch 0 (218→219) taken 1 times.
✓ Branch 2 (221→222) taken 1 times.
✓ Branch 4 (224→225) taken 1 times.
✓ Branch 6 (225→226) taken 1 times.
✓ Branch 8 (226→227) taken 1 times.
✓ Branch 10 (227→228) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(author2Mail, "\"pierre.aubert@lapp.in2p3.fr\"")); |
| 356 | |||
| 357 | // Test maintainers array (single element) | ||
| 358 |
2/2✓ Branch 0 (235→236) taken 1 times.
✓ Branch 2 (236→237) taken 1 times.
|
1 | ConfigNode * mapMaintainers = mapProject->getChild("maintainers"); |
| 359 |
4/4✓ Branch 0 (240→241) taken 1 times.
✓ Branch 2 (243→244) taken 1 times.
✓ Branch 4 (246→247) taken 1 times.
✓ Branch 6 (247→248) taken 1 times.
|
5 | phoenix_assert(mapMaintainers != NULL); |
| 360 |
1/1✓ Branch 0 (254→255) taken 1 times.
|
1 | const VecConfigNode & vecMaintainers = mapMaintainers->getVecChild(); |
| 361 |
4/4✓ Branch 0 (257→258) taken 1 times.
✓ Branch 2 (260→261) taken 1 times.
✓ Branch 4 (263→264) taken 1 times.
✓ Branch 6 (265→266) taken 1 times.
|
5 | phoenix_assert(vecMaintainers.size() == 1lu); |
| 362 | |||
| 363 | // Check maintainer | ||
| 364 |
2/2✓ Branch 0 (273→274) taken 1 times.
✓ Branch 2 (274→275) taken 1 times.
|
1 | const ConfigNode * maintainerFirstName = vecMaintainers[0]->getChild("firstName"); |
| 365 |
6/6✓ Branch 0 (278→279) taken 1 times.
✓ Branch 2 (281→282) taken 1 times.
✓ Branch 4 (284→285) taken 1 times.
✓ Branch 6 (285→286) taken 1 times.
✓ Branch 8 (286→287) taken 1 times.
✓ Branch 10 (287→288) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(maintainerFirstName, "\"Aubert\"")); |
| 366 |
2/2✓ Branch 0 (296→297) taken 1 times.
✓ Branch 2 (297→298) taken 1 times.
|
1 | const ConfigNode * maintainerLastName = vecMaintainers[0]->getChild("lastName"); |
| 367 |
6/6✓ Branch 0 (301→302) taken 1 times.
✓ Branch 2 (304→305) taken 1 times.
✓ Branch 4 (307→308) taken 1 times.
✓ Branch 6 (308→309) taken 1 times.
✓ Branch 8 (309→310) taken 1 times.
✓ Branch 10 (310→311) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(maintainerLastName, "\"Pierre\"")); |
| 368 |
2/2✓ Branch 0 (319→320) taken 1 times.
✓ Branch 2 (320→321) taken 1 times.
|
1 | const ConfigNode * maintainerMail = vecMaintainers[0]->getChild("mail"); |
| 369 |
6/6✓ Branch 0 (324→325) taken 1 times.
✓ Branch 2 (327→328) taken 1 times.
✓ Branch 4 (330→331) taken 1 times.
✓ Branch 6 (331→332) taken 1 times.
✓ Branch 8 (332→333) taken 1 times.
✓ Branch 10 (333→334) taken 1 times.
|
5 | phoenix_assert(checkKeyMapValue(maintainerMail, "\"pierre.aubert@lapp.in2p3.fr\"")); |
| 370 | 1 | } | |
| 371 | |||
| 372 | 1 | int main(int argc, char** argv){ | |
| 373 | 1 | testCheckValue(); | |
| 374 | 1 | checkParserTomlFail(); | |
| 375 | 1 | checkParserToml(); | |
| 376 | 1 | checkTomlList(); | |
| 377 | 1 | checkTomlEmptyList(); | |
| 378 | 1 | checkTomNestedlList(); | |
| 379 | 1 | checkTomNestedlMap(); | |
| 380 | 1 | checkTomTable(); | |
| 381 | 1 | checkTomlCompactDico(); | |
| 382 | 1 | checkTomlCompactDico2(); | |
| 383 | 1 | checkListOfDico(); | |
| 384 | 1 | return 0; | |
| 385 | } | ||
| 386 | |||
| 387 | |||
| 388 |