]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxFileSystem test
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 28 Mar 2004 20:44:26 +0000 (20:44 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 28 Mar 2004 20:44:26 +0000 (20:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/Makefile.in
tests/filesys/filesys.cpp [new file with mode: 0644]
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/test.bkl
tests/test.dsp

index f61270208b5685a8cc66acfbcc875eed7d33f612..314755b0ec642815d9b6f6631d23daa8113f2db2 100644 (file)
@@ -39,7 +39,8 @@ TEST_OBJECTS =  \
        test_test.o \
        test_main.o \
        test_formatconverter.o \
        test_test.o \
        test_main.o \
        test_formatconverter.o \
-       test_regex.o
+       test_regex.o \
+       test_filesys.o
 
 ### Conditionally set variables: ###
 
 
 ### Conditionally set variables: ###
 
@@ -114,6 +115,9 @@ test_formatconverter.o: $(srcdir)/formatconverter/formatconverter.cpp
 test_regex.o: $(srcdir)/regex/regex.cpp
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
 
 test_regex.o: $(srcdir)/regex/regex.cpp
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
 
+test_filesys.o: $(srcdir)/filesys/filesys.cpp
+       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
+
 
 # Include dependency info, if present:
 @IF_GNU_MAKE@-include .deps/*.d
 
 # Include dependency info, if present:
 @IF_GNU_MAKE@-include .deps/*.d
diff --git a/tests/filesys/filesys.cpp b/tests/filesys/filesys.cpp
new file mode 100644 (file)
index 0000000..64b12d8
--- /dev/null
@@ -0,0 +1,105 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/filesys/filesys.cpp
+// Purpose:     wxFileSystem unit test
+// Author:      Vaclav Slavik
+// Created:     2004-03-28
+// RCS-ID:      $Id$
+// Copyright:   (c) 2004 Vaclav Slavik
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "wx/wx.h"
+#include "wx/filesys.h"
+
+#include "wx/cppunit.h"
+
+#if wxUSE_FILESYSTEM
+
+// ----------------------------------------------------------------------------
+// helpers
+// ----------------------------------------------------------------------------
+
+// a hack to let us use wxFileSystemHandler's protected methods:
+class UrlTester : public wxFileSystemHandler
+{
+public:
+    UrlTester() : wxFileSystemHandler() {}
+
+    wxString Protocol(const wxString& p) { return GetProtocol(p); }
+    wxString LeftLocation(const wxString& p) { return GetLeftLocation(p); }
+    wxString RightLocation(const wxString& p) { return GetRightLocation(p); }
+    wxString Anchor(const wxString& p) { return GetAnchor(p); }
+
+    bool CanOpen(const wxString& WXUNUSED(url)) { return false; }
+    wxFSFile *OpenFile(wxFileSystem& WXUNUSED(fs),
+                       const wxString& WXUNUSED(url)) { return NULL; }
+
+
+};
+
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class FileSystemTestCase : public CppUnit::TestCase
+{
+public:
+    FileSystemTestCase() { }
+
+private:
+    CPPUNIT_TEST_SUITE( FileSystemTestCase );
+        CPPUNIT_TEST( UrlParsing );
+    CPPUNIT_TEST_SUITE_END();
+
+    void UrlParsing();
+
+    DECLARE_NO_COPY_CLASS(FileSystemTestCase);
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( FileSystemTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileSystemTestCase, "FileSystemTestCase" );
+
+void FileSystemTestCase::UrlParsing()
+{
+    static const struct Data
+    {
+        const wchar_t *url;
+        const wchar_t *protocol, *left, *right, *anchor;
+    } data[] =
+    {
+        // simple case:
+        { _T("http://www.root.cz/index.html"),
+                _T("http"), _T(""), _T("//www.root.cz/index.html"), _T("")},
+        // anchors:
+        { _T("http://www.root.cz/index.html#lbl"),
+                _T("http"), _T(""), _T("//www.root.cz/index.html"), _T("lbl")},
+        // file is default protocol:
+        { _T("testfile.html"),
+                _T("file"), _T(""), _T("testfile.html"), _T("")},
+        // stacked protocols:
+        { _T("file:myzipfile.zip#zip:index.htm"),
+                _T("zip"), _T("file:myzipfile.zip"), _T("index.htm"), _T("")},
+        // changes to ':' parsing often break things:
+        { _T("file:a#b:foo"),
+                _T("b"), _T("file:a"), _T("foo"), _T("")}
+    };
+
+    UrlTester tst;
+    for ( size_t n = 0; n < WXSIZEOF(data); n++ )
+    {
+        const Data& d = data[n];
+        CPPUNIT_ASSERT( tst.Protocol(d.url) == d.protocol );
+        CPPUNIT_ASSERT( tst.LeftLocation(d.url) == d.left );
+        CPPUNIT_ASSERT( tst.RightLocation(d.url) == d.right );
+        CPPUNIT_ASSERT( tst.Anchor(d.url) == d.anchor );
+    }
+}
+
+#endif // wxUSE_FILESYSTEM
index e6bfd8f9d67cbc2104ae6da4a0658064e6643b9b..21ff5824cd466ddab1eabda05fca74943d7d246b 100644 (file)
@@ -33,7 +33,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_test.obj \
        $(OBJS)\test_main.obj \
        $(OBJS)\test_formatconverter.obj \
        $(OBJS)\test_test.obj \
        $(OBJS)\test_main.obj \
        $(OBJS)\test_formatconverter.obj \
-       $(OBJS)\test_regex.obj
+       $(OBJS)\test_regex.obj \
+       $(OBJS)\test_filesys.obj
 
 ### Conditionally set variables: ###
 
 
 ### Conditionally set variables: ###
 
@@ -164,3 +165,6 @@ $(OBJS)\test_formatconverter.obj: .\formatconverter\formatconverter.cpp
 
 $(OBJS)\test_regex.obj: .\regex\regex.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
 $(OBJS)\test_regex.obj: .\regex\regex.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
+
+$(OBJS)\test_filesys.obj: .\filesys\filesys.cpp
+       $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
index c9274de0f0b3b4024cdd1c07d69fb145b46f380c..15d4f09c9278e74455e4d96ab076f42bca426cda 100644 (file)
@@ -24,7 +24,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_test.o \
        $(OBJS)\test_main.o \
        $(OBJS)\test_formatconverter.o \
        $(OBJS)\test_test.o \
        $(OBJS)\test_main.o \
        $(OBJS)\test_formatconverter.o \
-       $(OBJS)\test_regex.o
+       $(OBJS)\test_regex.o \
+       $(OBJS)\test_filesys.o
 
 ### Conditionally set variables: ###
 
 
 ### Conditionally set variables: ###
 
@@ -159,4 +160,7 @@ $(OBJS)\test_formatconverter.o: ./formatconverter/formatconverter.cpp
 $(OBJS)\test_regex.o: ./regex/regex.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
 $(OBJS)\test_regex.o: ./regex/regex.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
+$(OBJS)\test_filesys.o: ./filesys/filesys.cpp
+       $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
+
 .PHONY: all clean
 .PHONY: all clean
index 4e421ea4f4c72f2c963c659cad69856ea97bdc8e..7da294623b2bf6a6a6d7232eafc260eae78c4b8f 100644 (file)
@@ -26,7 +26,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_test.obj \
        $(OBJS)\test_main.obj \
        $(OBJS)\test_formatconverter.obj \
        $(OBJS)\test_test.obj \
        $(OBJS)\test_main.obj \
        $(OBJS)\test_formatconverter.obj \
-       $(OBJS)\test_regex.obj
+       $(OBJS)\test_regex.obj \
+       $(OBJS)\test_filesys.obj
 
 ### Conditionally set variables: ###
 
 
 ### Conditionally set variables: ###
 
@@ -220,3 +221,6 @@ $(OBJS)\test_formatconverter.obj: .\formatconverter\formatconverter.cpp
 
 $(OBJS)\test_regex.obj: .\regex\regex.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
 $(OBJS)\test_regex.obj: .\regex\regex.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
+
+$(OBJS)\test_filesys.obj: .\filesys\filesys.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
index 92df94af6802633df84bef1be10f583b3b1d5250..4d92c5ce5c690954987db1e7d3a24eb61a2b90c6 100644 (file)
@@ -174,7 +174,8 @@ TEST_OBJECTS =  &
        $(OBJS)\test_test.obj &
        $(OBJS)\test_main.obj &
        $(OBJS)\test_formatconverter.obj &
        $(OBJS)\test_test.obj &
        $(OBJS)\test_main.obj &
        $(OBJS)\test_formatconverter.obj &
-       $(OBJS)\test_regex.obj
+       $(OBJS)\test_regex.obj &
+       $(OBJS)\test_filesys.obj
 
 
 all : $(OBJS)
 
 
 all : $(OBJS)
@@ -214,3 +215,6 @@ $(OBJS)\test_formatconverter.obj :  .AUTODEPEND .\formatconverter\formatconverte
 
 $(OBJS)\test_regex.obj :  .AUTODEPEND .\regex\regex.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
 $(OBJS)\test_regex.obj :  .AUTODEPEND .\regex\regex.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+
+$(OBJS)\test_filesys.obj :  .AUTODEPEND .\filesys\filesys.cpp
+       $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
index 920ee3d094355c3160d23c7c472add05cee95617..6fa02eaa0cf5dcfb2f92db02198d26e04c4c71e9 100644 (file)
@@ -12,6 +12,7 @@
             mbconv/main.cpp
             formatconverter/formatconverter.cpp
             regex/regex.cpp
             mbconv/main.cpp
             formatconverter/formatconverter.cpp
             regex/regex.cpp
+            filesys/filesys.cpp
         </sources>
         <wx-lib>base</wx-lib>
     </exe>
         </sources>
         <wx-lib>base</wx-lib>
     </exe>
index 31a4a54146b8a17a314305305686b92e9741573d..ec16fc8b2e734d641dd39bfb4eb60075f7edcf0d 100644 (file)
@@ -435,6 +435,10 @@ LINK32=link.exe
 # PROP Default_Filter ""
 # Begin Source File
 
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\filesys\filesys.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\formatconverter\formatconverter.cpp
 # End Source File
 # Begin Source File
 SOURCE=.\formatconverter\formatconverter.cpp
 # End Source File
 # Begin Source File