#ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #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 static bool test_inifile() { std::auto_ptr cf; string fname("/tmp/stardict.cfg"); tmp_file tf(fname); cf.reset(new inifile(fname)); bool res = is_test_passed(cf.get()); cf.reset(0); return res; } int main(int argc, char *argv[]) { if (!test_inifile()) { std::cerr<<"ini file test failed"<