Skip to content
Snippets Groups Projects

Update toml

Merged Pierre Aubert requested to merge update_toml into master
2 files
+ 131
11
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -178,12 +178,68 @@ bool checkTomNestedlList(){
return b;
}
///Check the embeded dico
/** @return true on success, false otherwise
*/
bool checkTomNestedlMap(){
std::cout << "checkTomNestedlMap :" << std::endl;
std::string fileContent("[first.second]\nsome_value = 42\n\n");
std::string tomlFile("test_toml_nested_map.toml");
if(!saveFileContent(tomlFile, fileContent)){return false;}
DicoValue dico;
if(!parser_toml(dico, tomlFile)){return false;}
std::cout << "checkTomNestedlMap : output DicoValue :" << std::endl;
dico.print();
bool b(true);
DicoValue * mapFirst = dico.getMap("first");
bool isKeyExist = mapFirst != NULL;
std::cout << "checkTomNestedlMap : isKeyExist = " << isKeyExist << std::endl;
DicoValue * mapSecond = mapFirst->getMap("second");
DicoValue * mapOtherListKey = mapSecond->getMap("some_value");
b &= checkKeyMapValue(mapOtherListKey, "42");
std::cout << "checkTomNestedlMap : b = " << b << std::endl;
return b;
}
///Check the embeded dico
/** @return true on success, false otherwise
*/
bool checkTomTable(){
std::cout << "checkTomTable :" << std::endl;
std::string fileContent("[[program]]\nname = \"shadok\"\n\n[[program]]\nname = \"gibi\"\n\n");
std::string tomlFile("test_toml_table.toml");
if(!saveFileContent(tomlFile, fileContent)){return false;}
DicoValue dico;
if(!parser_toml(dico, tomlFile)){return false;}
std::cout << "checkTomTable : output DicoValue :" << std::endl;
dico.print();
bool b(true);
DicoValue * mapProgram = dico.getMap("program");
bool isKeyExist = mapProgram != NULL;
std::cout << "checkTomTable : isKeyExist = " << isKeyExist << std::endl;
const VecDicoValue & vecProgramValue = mapProgram->getVecChild();
b &= vecProgramValue.size() == 2lu;
b &= vecProgramValue[0].getValue() == "\"shadok\"";
b &= vecProgramValue[1].getValue() == "\"gibi\"";
std::cout << "checkTomTable : b = " << b << std::endl;
return b;
}
int main(int argc, char** argv){
testCheckValue();
bool b(checkParserToml());
b &= checkTomlList();
b &= checkTomNestedlList();
b &= checkTomNestedlMap();
b &= checkTomTable();
std::cout << "Final : " << b << std::endl;
return b - 1;
}
Loading