]> git.saurik.com Git - wxWidgets.git/commitdiff
started wxFileConfig unit test
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Oct 2004 23:17:19 +0000 (23:17 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Oct 2004 23:17:19 +0000 (23:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/fileconf/fileconf.cpp [new file with mode: 0644]
tests/test.bkl

diff --git a/tests/fileconf/fileconf.cpp b/tests/fileconf/fileconf.cpp
new file mode 100644 (file)
index 0000000..ddd59f2
--- /dev/null
@@ -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
+
index 22cc97cfe00dc5a4beda0d0b2772257a14832b7c..26b01b399b7b1d092eb058fffb8199d16ebcd1cb 100644 (file)
@@ -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