/* * This file part of StarDict - A international dictionary for GNOME. * http://stardict.sourceforge.net * Copyright (C) 2005 Evgeniy * * This program 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. * * This program 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 Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include #include #include #include #include "config_file.hpp" #include "inifile.hpp" #ifdef CONFIG_GNOME # include "gconf_file.hpp" #endif using std::string; using std::ostream_iterator; typedef std::list strlist; std::ostream& operator<<(std::ostream& os, const strlist &sl) { std::copy(sl.begin(), sl.end(), ostream_iterator(os, "\n")); return os; } struct tmp_file { string fname; tmp_file(const string& fn) : fname(fn) {} ~tmp_file() { if (remove(fname.c_str())==-1) std::cerr<<"can not remove: "<read_##type("/stardict-test", #type, type##_val); \ if (type##_val!=def_val) { \ std::cerr<<"type: "<<#type<<", default value was changed"<write_##type("/stardict-test", #type, some_val); \ cf->read_##type("/stardict-test", #type, type##_val); \ if (type##_val!=some_val) { \ std::cerr<<"type: "<<#type<<", default value was NOT changed"< cf; cf.reset(new gconf_file("/apps/stardict")); tmp_file tf=tmp1; tmp_file tf1=tmp2; bool res=is_test_passed(cf.get()); cf.reset(0); system("gconftool-2 --shutdown"); return res; } #endif bool test_inifile() { std::auto_ptr cf; string fname("/tmp/stardict.cfg"); tmp_file tf(fname); cf.reset(new inifile(fname)); return is_test_passed(cf.get()); } int main(int argc, char *argv[]) { if (!test_inifile()) { std::cerr<<"ini file test failed"<