middle of porting; unstable, don't checkout; refs #1
This commit is contained in:
72
test/configfile_test.cxx
Normal file
72
test/configfile_test.cxx
Normal file
@@ -0,0 +1,72 @@
|
||||
/** @file
|
||||
|
||||
$Id$
|
||||
|
||||
$Date$
|
||||
$Author$
|
||||
|
||||
@copy © Marc Wäckerlin
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2005/04/07 20:55:21 marc
|
||||
Oops, there's a make distcheck...? Now it works.
|
||||
|
||||
Revision 1.1 2005/01/07 00:31:38 marc
|
||||
initial version
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <mrw/configfile.hxx>
|
||||
#include <mrw/file.hxx>
|
||||
#include <mrw/stdext.hxx> // ifelse
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <stdlib.h> // getenv
|
||||
|
||||
class ConfigFileTest: public CppUnit::TestFixture {
|
||||
public:
|
||||
void CheckFile() {
|
||||
std::string srcdir(mrw::ifelse(getenv("srcdir"), "."));
|
||||
mrw::File::copy(srcdir+"/configfile.ini", "configfile2.ini");
|
||||
mrw::ConfigFileWriter config("configfile2.ini");
|
||||
CPPUNIT_ASSERT(config("", "xxx", ".")=="yyy");
|
||||
CPPUNIT_ASSERT(config("Section", "abc", ".")=="");
|
||||
CPPUNIT_ASSERT(config("Section", "def", ".")=="hallo welt");
|
||||
CPPUNIT_ASSERT(config("Section", "ghi", ".")=="");
|
||||
CPPUNIT_ASSERT(config("Section", "jkl", ".")=="mn\n op qr\n st");
|
||||
CPPUNIT_ASSERT(config("Other Section", "1234", ".")=="5678=90");
|
||||
CPPUNIT_ASSERT(config("Other Section", "here we are", ".")
|
||||
=="some contents");
|
||||
CPPUNIT_ASSERT(config("Other Section", "here", ".")=="");
|
||||
config("", "xxx", ".")="0";
|
||||
config("Section", "abc", ".")="1";
|
||||
CPPUNIT_ASSERT(config("New Section", "a first one", "sgadd")=="sgadd");
|
||||
config("Section", "def", ".")="Und=Tschuess";
|
||||
config("Section", "ghi", ".")="3";
|
||||
config("Section", "jkl", ".")="4";
|
||||
config("Other Section", "1234", ".")="5";
|
||||
config("Other Section", "here we are", ".")="6";
|
||||
config("Other Section", "here", ".")="7";
|
||||
CPPUNIT_ASSERT(config("Other Section", "no no", ".")==".");
|
||||
CPPUNIT_ASSERT(config("Other Section", "no no no", ".")==".");
|
||||
CPPUNIT_ASSERT(config("Other Section", "yes", ".")==".");
|
||||
CPPUNIT_ASSERT(config("Section", "guguseli", "dadaa")=="dadaa");
|
||||
CPPUNIT_ASSERT(config("Section", "guguseli zwei", "dadaa")=="dadaa");
|
||||
CPPUNIT_ASSERT(config("Section", "guguseli drei", "dadaa")=="dadaa");
|
||||
CPPUNIT_ASSERT(config("New Section", "one more", ".")==".");
|
||||
}
|
||||
CPPUNIT_TEST_SUITE(ConfigFileTest);
|
||||
CPPUNIT_TEST(CheckFile);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
};
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ConfigFileTest);
|
||||
|
||||
int main() {
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
|
||||
return runner.run() ? 0 : 1;
|
||||
}
|
Reference in New Issue
Block a user