// src/testsuite/test-stepforward.cc - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // // This file is part of SGPEMv2. // // This is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // SGPEMv2 is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /* This executable tests for workingness of the save preferences method, * and nothing else. */ #include "config.h" #include "glibmm/ustring.h" #include "backend/global_preferences.hh" #include #include // from here and further until the bottom, all to throw away I suppose int main(int argc, char** argv) { using namespace sgpem; using Glib::ustring; using std::cout; using std::endl; using std::ostringstream; GlobalPreferences& gp = GlobalPreferences::get_instance(); if (argc < 2) { cout << "GlobalPreferences serialization test program" << endl; cout << "Syntax: test-global_preferences_serialization [mod1 mod2 ...][% pol1 pol2 ...]" << endl << endl; cout << "This test add modules directories (mod1 mod2 ...) and modules directories (mod1 mod2 ...)" << endl << "to GlobalPreferences, write it to the configuration file " << gp.get_config_filename() << ", read it and compare with saved one." << endl << endl; } int i = 1; while (i < argc && (*argv[i] != '%')) { gp.add_modules_dir( Glib::ustring(argv[i]) ); i++; } i++; while (i < argc) { gp.add_policies_dir( Glib::ustring(argv[i]) ); i++; } /* GlobalPreferencesSerializer gpSer(gp); gpSer.file_write(Glib::ustring(argv[1])); */ cout << "Config saved" << endl; gp.write_configrc(); // TODO - terminate me as soon as possible - please!!! gp.write_configrc(cout); ostringstream os1; cout << "Preferences writed into os1 (t1)" << endl << endl; gp.write_configrc(os1); i = 1; while (i < argc && (*argv[i] != '%')) { gp.add_modules_dir( Glib::ustring("bis-") + Glib::ustring(argv[i]) ); i++; } i++; while (i < argc) { gp.add_policies_dir( Glib::ustring("bis-") + Glib::ustring(argv[i]) ); i++; } cout << "Other data added" << endl << endl; gp.write_configrc(cout); ostringstream os2; cout << "Preferences writed into os2 (t2)" << endl << endl; gp.write_configrc(os2); cout << "Config readed from config file" << endl << endl; gp.load_configrc(); gp.write_configrc(cout); ostringstream os3; cout << "Preferences writed into os3 (t3)" << endl << endl; gp.write_configrc(os3); cout << "Comparing dump of (t1) and (t2): " << (os1.str() == os2.str() ? "equals" : "not equals") << endl; cout << "Comparing dump of (t1) and (t3): " << (os1.str() == os3.str() ? "equals" : "not equals") << endl; int ret = 1; if (os1.str() != os2.str() && os1.str() == os3.str()) { cout << "test successful" << endl; ret = 0; } else { cout << "test failed" << endl; ret = 1; } return ret; }