From: Vadim Zeitlin Date: Sun, 3 Oct 2004 23:17:19 +0000 (+0000) Subject: started wxFileConfig unit test X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/17c24d37c689fe17a771af0cf92db59798acf911 started wxFileConfig unit test git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/tests/fileconf/fileconf.cpp b/tests/fileconf/fileconf.cpp new file mode 100644 index 0000000000..ddd59f2aa1 --- /dev/null +++ b/tests/fileconf/fileconf.cpp @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/fileconf/fileconf.cpp +// Purpose: wxFileConf unit test +// Author: Vadim Zeitlin +// Created: 2004-09-19 +// RCS-ID: $Id$ +// Copyright: (c) 2004 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_FILECONFIG + +#ifndef WX_PRECOMP +#endif // WX_PRECOMP + +#include "wx/fileconf.h" +#include "wx/sstream.h" + +#include "wx/cppunit.h" + +static const wxChar *testconfig = +_T("[root]\n") +_T("entry=value\n") +_T("[root/group1]\n") +_T("[root/group1/subgroup]\n") +_T("subentry=subvalue\n") +_T("[root/group2]\n") +; + +// ---------------------------------------------------------------------------- +// test class +// ---------------------------------------------------------------------------- + +class FileConfigTestCase : public CppUnit::TestCase +{ +public: + FileConfigTestCase() { } + +private: + CPPUNIT_TEST_SUITE( FileConfigTestCase ); + CPPUNIT_TEST( HasGroup ); + CPPUNIT_TEST_SUITE_END(); + + void HasGroup(); + + DECLARE_NO_COPY_CLASS(FileConfigTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( FileConfigTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileConfigTestCase, "FileConfigTestCase" ); + +void FileConfigTestCase::HasGroup() +{ + wxStringInputStream sis(testconfig); + wxFileConfig fc(sis); + + CPPUNIT_ASSERT( fc.HasGroup(_T("root")) ); + CPPUNIT_ASSERT( fc.HasGroup(_T("root/group1")) ); + CPPUNIT_ASSERT( fc.HasGroup(_T("root/group1/subgroup")) ); + CPPUNIT_ASSERT( fc.HasGroup(_T("root/group2")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("foot")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("root/group")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("root//subgroup")) ); +} + +#endif // wxUSE_FILECONFIG + diff --git a/tests/test.bkl b/tests/test.bkl index 22cc97cfe0..26b01b399b 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -13,6 +13,7 @@ formatconverter/formatconverter.cpp regex/regex.cpp regex/wxregex.cpp + fileconf/fileconf.cpp filename/filename.cpp filesys/filesys.cpp arrays/arrays.cpp