18 return dv.
save(fileName.
replace(
".txt",
".dico").
replace(CMAKE_CURRENT_TEST_DIR, CMAKE_CURRENT_BUILD_DIR));
27 b &= dico.
getMap(
"NonExistingmap") == NULL;
37 if(!dv.
load(fileName)){
38 std::cerr <<
"testDicoValue : cannot load file '"<<fileName<<
"'" << std::endl;
41 std::vector<DicoValue> & vecChild = dv.
getVecChild();
45 b &= dv.
getMap(
"NonExistingmap") == NULL;
51 std::cout <<
"testDicoValue : value of key : '" << value.
getValue() <<
"' with key '" << value.
getKey() <<
"', vecChild.size = " << vecChild.size() << std::endl;
73 if(!dv.
load(fileName)){
74 std::cerr <<
"testDicoValue2 : cannot load file '"<<fileName<<
"'" << std::endl;
93 std::cerr <<
"testDicoValueKeyPtr : DicoValue for value "<<expectedValue<<
" not found!!!" << std::endl;
97 return dv->
getValue<
int>() == expectedValue;
106 if(!dv.
load(fileName)){
107 std::cerr <<
"testDicoValue3 : cannot load file '"<<fileName<<
"'" << std::endl;
125 std::cerr <<
"testDicoVecValueKeyPtr : DicoValue for value "<<expectedValue<<
" not found!!!" << std::endl;
129 if(vecVal.size() != 3lu){
130 std::cerr <<
"testDicoVecValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl;
134 for(
int i(0); i < 3; ++i){
135 std::cout <<
"testDicoVecValueKeyPtr : value["<<i<<
"] = " << vecVal[i].getValue<
int>() <<
", expect = " << (i + expectedValue) << std::endl;
136 b &= vecVal[i].getValue<
int>() == expectedValue + i;
147 if(!dv.
load(fileName)){
148 std::cerr <<
"testDicoVecValue : cannot load file '"<<fileName<<
"'" << std::endl;
164 if(!dv.
load(fileName)){
165 std::cerr <<
"testDicoVecString : cannot load file '"<<fileName<<
"'" << std::endl;
196 std::cerr <<
"testDicoDicoValueKeyPtr : DicoValue for value "<<expectedValue<<
" not found!!!" << std::endl;
200 if(mapVal.size() != 3lu){
201 std::cerr <<
"testDicoDicoValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl;
217 if(!dv.
load(fileName)){
218 std::cerr <<
"testDicoDicoString : cannot load file '"<<fileName<<
"'" << std::endl;
238 PPath fileName(
"config.txt");
242 b &= dico.
load(fileName);
251 PPath fileName(
"config.txt");
255 b &= !dico.
load(fileName);
264 PPath fileName(
"config_out.txt");
268 b &= dico.
save(fileName);
274 PPath fileName(CMAKE_CURRENT_TEST_DIR
"/testInputDicoMapDico.json");
285 int main(
int argc,
char** argv){
286 PPath fileName0(CMAKE_CURRENT_TEST_DIR
"/testInputDico.txt");
291 PPath fileName2(CMAKE_CURRENT_TEST_DIR
"/testInputDicoValue.txt");
295 PPath fileName3(CMAKE_CURRENT_TEST_DIR
"/testInputDicoValue.txt");
299 PPath fileNameVec(CMAKE_CURRENT_TEST_DIR
"/testInputDicoVecValue.txt");
303 PPath fileNameVecString(CMAKE_CURRENT_TEST_DIR
"/testInputDicoVecString.txt");
307 PPath fileNameDicoString(CMAKE_CURRENT_TEST_DIR
"/testInputDicoMapDico.txt");
std::map< PString, DicoValue > MapDicoValue
Vector of DicoValue.
std::vector< DicoValue > VecDicoValue
Vector of DicoValue.
int main(int argc, char **argv)
bool checkConstDicoValue(const DicoValue &dico)
Check a const DicoValue.
bool testDicoVecString(const PPath &fileName)
Test the DicoValue.
void testFromJSonToJSon()
Test JSON to JSON convertion.
bool testDicoVecValueKeyPtr(const DicoValue *dv, int expectedValue)
Test the value of the given DicoValue.
bool testDicoValue2(const PPath &fileName)
Test the DicoValue.
bool testDicoVecValue(const PPath &fileName)
Test the DicoValue.
bool testDicoDicoValueKeyPtr(const DicoValue *dv, int expectedValue)
Test the value of the given DicoValue.
bool testDicoValue3(const PPath &fileName)
Test the DicoValue.
bool saveDico(const DicoValue &dv, const PPath &fileName)
Save the given DicoValue in the given file.
bool testDicoValueKey(const DicoValue &dv, int expectedValue)
Test the value of the given DicoValue.
bool testDicoDicoString(const PPath &fileName)
Test the DicoValue.
bool testDicoSaveParsing(const PString &fileContent)
Check all the bad parsing.
bool testDicoBadParsing(const PString &fileContent)
Check all the bad parsing.
bool testDicoValueKeyPtr(const DicoValue *dv, int expectedValue)
Test the value of the given DicoValue.
bool testDicoValue(const PPath &fileName)
Test the DicoValue.
bool testDicoGoodParsing(const PString &fileContent)
Check all the good parsing.
void setVecChild(const std::vector< DicoValue > &vecChild)
Sets the vecChild of the DicoValue.
PString toString(const PString &valueDecorator="", PString baseIndentation="\t", PString baseNewLine="\n") const
Convert the DicoValue into a string.
const PString & getKey() const
Gets the key of the DicoValue.
bool isKeyExist(const PString &key) const
Say if the given key exists in the map of children.
bool fromString(const PString &content)
Create a DicoValue from a PString.
const std::vector< DicoValue > & getVecChild() const
Gets the vecChild of the DicoValue.
const DicoValue * getMap(const PString &key) const
Get a DicoValue in the map of the current one.
bool save(const PPath &fileName, const PString &valueDecorator="", PString baseIndentation="\t", PString baseNewLine="\n") const
Save the DicoValue with a text file.
void setValue(const PString &value)
Sets the value of the DicoValue.
const std::map< PString, DicoValue > & getMapChild() const
Gets the mapChild of the DicoValue.
T getValue() const
Convert the value of the current DicoValue into a type.
bool load(const PPath &fileName)
Load the DicoValue with a text file.
void setMapChild(const std::map< PString, DicoValue > &mapChild)
Sets the mapChild of the DicoValue.
Path of a directory or a file.
bool saveFileContent(const PString &content) const
Save a PString in a file.
PPath getFileName() const
Get the name of the file, from last char to /.
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.