added wxFileSystem test
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,7 +39,8 @@ TEST_OBJECTS = \
|
|||||||
test_test.o \
|
test_test.o \
|
||||||
test_main.o \
|
test_main.o \
|
||||||
test_formatconverter.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
|
test_regex.o: $(srcdir)/regex/regex.cpp
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
test_filesys.o: $(srcdir)/filesys/filesys.cpp
|
||||||
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# Include dependency info, if present:
|
# Include dependency info, if present:
|
||||||
@IF_GNU_MAKE@-include .deps/*.d
|
@IF_GNU_MAKE@-include .deps/*.d
|
||||||
|
105
tests/filesys/filesys.cpp
Normal file
105
tests/filesys/filesys.cpp
Normal file
@@ -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
|
@@ -33,7 +33,8 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_test.obj \
|
$(OBJS)\test_test.obj \
|
||||||
$(OBJS)\test_main.obj \
|
$(OBJS)\test_main.obj \
|
||||||
$(OBJS)\test_formatconverter.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
|
$(OBJS)\test_regex.obj: .\regex\regex.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
|
||||||
|
|
||||||
|
$(OBJS)\test_filesys.obj: .\filesys\filesys.cpp
|
||||||
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
|
||||||
|
@@ -24,7 +24,8 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_test.o \
|
$(OBJS)\test_test.o \
|
||||||
$(OBJS)\test_main.o \
|
$(OBJS)\test_main.o \
|
||||||
$(OBJS)\test_formatconverter.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
|
$(OBJS)\test_regex.o: ./regex/regex.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_filesys.o: ./filesys/filesys.cpp
|
||||||
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
@@ -26,7 +26,8 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_test.obj \
|
$(OBJS)\test_test.obj \
|
||||||
$(OBJS)\test_main.obj \
|
$(OBJS)\test_main.obj \
|
||||||
$(OBJS)\test_formatconverter.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
|
$(OBJS)\test_regex.obj: .\regex\regex.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
|
||||||
|
|
||||||
|
$(OBJS)\test_filesys.obj: .\filesys\filesys.cpp
|
||||||
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
|
||||||
|
@@ -174,7 +174,8 @@ TEST_OBJECTS = &
|
|||||||
$(OBJS)\test_test.obj &
|
$(OBJS)\test_test.obj &
|
||||||
$(OBJS)\test_main.obj &
|
$(OBJS)\test_main.obj &
|
||||||
$(OBJS)\test_formatconverter.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
|
$(OBJS)\test_regex.obj : .AUTODEPEND .\regex\regex.cpp
|
||||||
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_filesys.obj : .AUTODEPEND .\filesys\filesys.cpp
|
||||||
|
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
mbconv/main.cpp
|
mbconv/main.cpp
|
||||||
formatconverter/formatconverter.cpp
|
formatconverter/formatconverter.cpp
|
||||||
regex/regex.cpp
|
regex/regex.cpp
|
||||||
|
filesys/filesys.cpp
|
||||||
</sources>
|
</sources>
|
||||||
<wx-lib>base</wx-lib>
|
<wx-lib>base</wx-lib>
|
||||||
</exe>
|
</exe>
|
||||||
|
@@ -435,6 +435,10 @@ LINK32=link.exe
|
|||||||
# PROP Default_Filter ""
|
# PROP Default_Filter ""
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\filesys\filesys.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\formatconverter\formatconverter.cpp
|
SOURCE=.\formatconverter\formatconverter.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
Reference in New Issue
Block a user