diff --git a/src/testsuite/test-key_file.cc b/src/testsuite/test-key_file.cc new file mode 100644 index 0000000..6c31b97 --- /dev/null +++ b/src/testsuite/test-key_file.cc @@ -0,0 +1,102 @@ +// 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/key_file.hh" +#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; + + if((argc<4) || (argc%2)!=0) + { + cout << "KeyFile class test program" << endl; + cout << "Syntax: test-key_file filename key1 value1 [key2 value2...]" << endl; + cout << "total number of parameters must be odd." + << endl << endl; + cout << "This test create a KeyFile object, fill it with all key/value pairs," << endl + << "write it to the file \"filename\", read it into a new KeyFile object" << endl + << "and compare all readed values against original values." << endl << endl + << "If all key/values match the program print \"Test was successful\" and return 0." << endl + << "If some key/values doesn't match the program print \"Test failed\" and return 1." + << endl << endl; + cout << "If there isn't any parameter or bad number of parameters return 2." + << endl << endl; + cout << "NOTE: 1) Test fails with invalid filenames or duplicated key in input." + << endl; + cout << " 2) File \"filename\" remains in current directory after test execution." + << endl << endl; + return 2; + } + + KeyFile kfile; + KeyFile kfile_bis; + + // fill KeyFile object + for(int index = 2; index