void mw::XMLParserTestFixture::testSaveThenLoadDictInList() { mw::Data sub_dict1(M_DICTIONARY, 2); sub_dict1.addElement("four", mw::Data(14L)); sub_dict1.addElement("six", mw::Data(16L)); mw::Data sub_dict2(M_DICTIONARY, 2); sub_dict2.addElement("four", mw::Data(24L)); sub_dict2.addElement("six", mw::Data(26L)); mw::Data test_list(M_LIST, 2); test_list.setElement(0, sub_dict1); test_list.setElement(1, sub_dict2); testVar->setValue(test_list); mw::VariableSave::saveExperimentwideVariables(temp_xml_file_path); mw::Data test_data(5L); testVar->setValue(test_data); CPPUNIT_ASSERT(testVar->getValue().getInteger() == 5); mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path); CPPUNIT_ASSERT(testVar->getValue() == test_list); }
void mw::XMLParserTestFixture::testSaveThenLoadDictInDict() { mw::Datum sub_dict1(M_DICTIONARY, 2); sub_dict1.addElement("four", mw::Datum(14L)); sub_dict1.addElement("six", mw::Datum(16L)); mw::Datum sub_dict2(M_DICTIONARY, 2); sub_dict2.addElement("four", mw::Datum(24L)); sub_dict2.addElement("six", mw::Datum(26L)); mw::Datum main_dict(M_DICTIONARY, 2); main_dict.addElement("one", sub_dict1); main_dict.addElement("two", sub_dict2); testVar->setValue(main_dict); mw::VariableSave::saveExperimentwideVariables(temp_xml_file_path); mw::Datum test_data(5L); testVar->setValue(test_data); CPPUNIT_ASSERT(testVar->getValue().getInteger() == 5); mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path); CPPUNIT_ASSERT(testVar->getValue() == main_dict); }
void mw::XMLParserTestFixture::testLoadDictionaryInDictionary() { CPPUNIT_ASSERT(testVar->getValue().getFloat() == 0.0); const char *xml_text = "<?xml version=\"1.0\"?>" "<monkeyml version=\"1.1\">" " <variable_assignments>" " <variable_assignment variable=\"testVar\">" " <dictionary>" " <dictionary_element>" " <key>one</key>" " <value>" " <dictionary>" " <dictionary_element>" " <key>four</key>" " <value type=\"integer\">14</value>" " </dictionary_element>" " <dictionary_element>" " <key>six</key>" " <value type=\"integer\">16</value>" " </dictionary_element>" " </dictionary>" " </value>" " </dictionary_element>" " <dictionary_element>" " <key>two</key>" " <value>" " <dictionary>" " <dictionary_element>" " <key>four</key>" " <value type=\"integer\">24</value>" " </dictionary_element>" " <dictionary_element>" " <key>six</key>" " <value type=\"integer\">26</value>" " </dictionary_element>" " </dictionary>" " </value>" " </dictionary_element>" " </dictionary>" " </variable_assignment>" " </variable_assignments>" "</monkeyml>"; writeToFile(xml_text); mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path); mw::Data sub_dict1(M_DICTIONARY, 2); sub_dict1.addElement("four", mw::Data(14L)); sub_dict1.addElement("six", mw::Data(16L)); mw::Data sub_dict2(M_DICTIONARY, 2); sub_dict2.addElement("four", mw::Data(24L)); sub_dict2.addElement("six", mw::Data(26L)); mw::Data main_dict(M_DICTIONARY, 2); main_dict.addElement("one", sub_dict1); main_dict.addElement("two", sub_dict2); CPPUNIT_ASSERT(testVar->getValue() == main_dict); }