Move dir tests from the console sample to DirTestCase
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -101,12 +101,9 @@
|
|||||||
|
|
||||||
// what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
|
// what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
|
||||||
// test, define it to 1 to do all tests.
|
// test, define it to 1 to do all tests.
|
||||||
#define TEST_ALL 0
|
#define TEST_ALL 1
|
||||||
|
|
||||||
|
|
||||||
#if TEST_ALL
|
#if TEST_ALL
|
||||||
#define TEST_DIR
|
|
||||||
#else // #if TEST_ALL
|
|
||||||
#define TEST_DATETIME
|
#define TEST_DATETIME
|
||||||
#define TEST_VOLUME
|
#define TEST_VOLUME
|
||||||
#define TEST_STDPATHS
|
#define TEST_STDPATHS
|
||||||
@@ -117,6 +114,7 @@
|
|||||||
#define TEST_INFO_FUNCTIONS
|
#define TEST_INFO_FUNCTIONS
|
||||||
#define TEST_MIME
|
#define TEST_MIME
|
||||||
#define TEST_DYNLIB
|
#define TEST_DYNLIB
|
||||||
|
#else // #if TEST_ALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// some tests are interactive, define this to run them
|
// some tests are interactive, define this to run them
|
||||||
@@ -132,192 +130,6 @@
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxDir
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifdef TEST_DIR
|
|
||||||
|
|
||||||
#include "wx/dir.h"
|
|
||||||
|
|
||||||
#ifdef __UNIX__
|
|
||||||
static const wxChar *ROOTDIR = wxT("/");
|
|
||||||
static const wxChar *TESTDIR = wxT("/usr/local/share");
|
|
||||||
#elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
|
|
||||||
static const wxChar *ROOTDIR = wxT("c:\\");
|
|
||||||
static const wxChar *TESTDIR = wxT("d:\\");
|
|
||||||
#else
|
|
||||||
#error "don't know where the root directory is"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void TestDirEnumHelper(wxDir& dir,
|
|
||||||
int flags = wxDIR_DEFAULT,
|
|
||||||
const wxString& filespec = wxEmptyString)
|
|
||||||
{
|
|
||||||
wxString filename;
|
|
||||||
|
|
||||||
if ( !dir.IsOpened() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool cont = dir.GetFirst(&filename, filespec, flags);
|
|
||||||
while ( cont )
|
|
||||||
{
|
|
||||||
wxPrintf(wxT("\t%s\n"), filename.c_str());
|
|
||||||
|
|
||||||
cont = dir.GetNext(&filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPuts(wxEmptyString);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TEST_ALL
|
|
||||||
|
|
||||||
static void TestDirEnum()
|
|
||||||
{
|
|
||||||
wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
|
|
||||||
|
|
||||||
wxString cwd = wxGetCwd();
|
|
||||||
if ( !wxDir::Exists(cwd) )
|
|
||||||
{
|
|
||||||
wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDir dir(cwd);
|
|
||||||
if ( !dir.IsOpened() )
|
|
||||||
{
|
|
||||||
wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating everything in current directory:"));
|
|
||||||
TestDirEnumHelper(dir);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating really everything in current directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating object files in current directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_DEFAULT, wxT("*.o*"));
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating directories in current directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_DIRS);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating files in current directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_FILES);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating files including hidden in current directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
|
|
||||||
|
|
||||||
dir.Open(ROOTDIR);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating everything in root directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_DEFAULT);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating directories in root directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_DIRS);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating files in root directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_FILES);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating files including hidden in root directory:"));
|
|
||||||
TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
|
|
||||||
|
|
||||||
wxPuts(wxT("Enumerating files in non existing directory:"));
|
|
||||||
wxDir dirNo(wxT("nosuchdir"));
|
|
||||||
TestDirEnumHelper(dirNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TEST_ALL
|
|
||||||
|
|
||||||
class DirPrintTraverser : public wxDirTraverser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
|
|
||||||
{
|
|
||||||
return wxDIR_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual wxDirTraverseResult OnDir(const wxString& dirname)
|
|
||||||
{
|
|
||||||
wxString path, name, ext;
|
|
||||||
wxFileName::SplitPath(dirname, &path, &name, &ext);
|
|
||||||
|
|
||||||
if ( !ext.empty() )
|
|
||||||
name << wxT('.') << ext;
|
|
||||||
|
|
||||||
wxString indent;
|
|
||||||
for ( const wxChar *p = path.c_str(); *p; p++ )
|
|
||||||
{
|
|
||||||
if ( wxIsPathSeparator(*p) )
|
|
||||||
indent += wxT(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrintf(wxT("%s%s\n"), indent.c_str(), name.c_str());
|
|
||||||
|
|
||||||
return wxDIR_CONTINUE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void TestDirTraverse()
|
|
||||||
{
|
|
||||||
wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
|
|
||||||
|
|
||||||
// enum all files
|
|
||||||
wxArrayString files;
|
|
||||||
size_t n = wxDir::GetAllFiles(TESTDIR, &files);
|
|
||||||
wxPrintf(wxT("There are %u files under '%s'\n"), n, TESTDIR);
|
|
||||||
if ( n > 1 )
|
|
||||||
{
|
|
||||||
wxPrintf(wxT("First one is '%s'\n"), files[0u].c_str());
|
|
||||||
wxPrintf(wxT(" last one is '%s'\n"), files[n - 1].c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// enum again with custom traverser
|
|
||||||
wxPuts(wxT("Now enumerating directories:"));
|
|
||||||
wxDir dir(TESTDIR);
|
|
||||||
DirPrintTraverser traverser;
|
|
||||||
dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TEST_ALL
|
|
||||||
|
|
||||||
static void TestDirExists()
|
|
||||||
{
|
|
||||||
wxPuts(wxT("*** Testing wxDir::Exists() ***"));
|
|
||||||
|
|
||||||
static const wxChar *dirnames[] =
|
|
||||||
{
|
|
||||||
wxT("."),
|
|
||||||
#if defined(__WXMSW__)
|
|
||||||
wxT("c:"),
|
|
||||||
wxT("c:\\"),
|
|
||||||
wxT("\\\\share\\file"),
|
|
||||||
wxT("c:\\dos"),
|
|
||||||
wxT("c:\\dos\\"),
|
|
||||||
wxT("c:\\dos\\\\"),
|
|
||||||
wxT("c:\\autoexec.bat"),
|
|
||||||
#elif defined(__UNIX__)
|
|
||||||
wxT("/"),
|
|
||||||
wxT("//"),
|
|
||||||
wxT("/usr/bin"),
|
|
||||||
wxT("/usr//bin"),
|
|
||||||
wxT("/usr///bin"),
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
|
|
||||||
{
|
|
||||||
wxPrintf(wxT("%-40s: %s\n"),
|
|
||||||
dirnames[n],
|
|
||||||
wxDir::Exists(dirnames[n]) ? wxT("exists")
|
|
||||||
: wxT("doesn't exist"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TEST_ALL
|
|
||||||
|
|
||||||
#endif // TEST_DIR
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDllLoader
|
// wxDllLoader
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1070,14 +882,6 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
#endif // TEST_SNGLINST
|
#endif // TEST_SNGLINST
|
||||||
|
|
||||||
#ifdef TEST_DIR
|
|
||||||
#if TEST_ALL
|
|
||||||
TestDirExists();
|
|
||||||
TestDirEnum();
|
|
||||||
#endif
|
|
||||||
TestDirTraverse();
|
|
||||||
#endif // TEST_DIR
|
|
||||||
|
|
||||||
#ifdef TEST_DYNLIB
|
#ifdef TEST_DYNLIB
|
||||||
TestDllListLoaded();
|
TestDllListLoaded();
|
||||||
#endif // TEST_DYNLIB
|
#endif // TEST_DYNLIB
|
||||||
|
@@ -69,6 +69,7 @@ TEST_OBJECTS = \
|
|||||||
test_stopwatch.o \
|
test_stopwatch.o \
|
||||||
test_timertest.o \
|
test_timertest.o \
|
||||||
test_exec.o \
|
test_exec.o \
|
||||||
|
test_dir.o \
|
||||||
test_filefn.o \
|
test_filefn.o \
|
||||||
test_filetest.o \
|
test_filetest.o \
|
||||||
test_filekind.o \
|
test_filekind.o \
|
||||||
@@ -410,6 +411,9 @@ test_timertest.o: $(srcdir)/events/timertest.cpp $(TEST_ODEP)
|
|||||||
test_exec.o: $(srcdir)/exec/exec.cpp $(TEST_ODEP)
|
test_exec.o: $(srcdir)/exec/exec.cpp $(TEST_ODEP)
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/exec/exec.cpp
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/exec/exec.cpp
|
||||||
|
|
||||||
|
test_dir.o: $(srcdir)/file/dir.cpp $(TEST_ODEP)
|
||||||
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/file/dir.cpp
|
||||||
|
|
||||||
test_filefn.o: $(srcdir)/file/filefn.cpp $(TEST_ODEP)
|
test_filefn.o: $(srcdir)/file/filefn.cpp $(TEST_ODEP)
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/file/filefn.cpp
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/file/filefn.cpp
|
||||||
|
|
||||||
|
216
tests/file/dir.cpp
Normal file
216
tests/file/dir.cpp
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: tests/file/dir.cpp
|
||||||
|
// Purpose: wxDir unit test
|
||||||
|
// Author: Francesco Montorsi (extracted from console sample)
|
||||||
|
// Created: 2010-06-19
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2010 wxWidgets team
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "testprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/dir.h"
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
|
#define DIRTEST_FOLDER wxString("dirTest_folder")
|
||||||
|
#define SEP wxFileName::GetPathSeparator()
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// test class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class DirTestCase : public CppUnit::TestCase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DirTestCase() { }
|
||||||
|
|
||||||
|
virtual void setUp();
|
||||||
|
virtual void tearDown();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CPPUNIT_TEST_SUITE( DirTestCase );
|
||||||
|
CPPUNIT_TEST( DirExists );
|
||||||
|
CPPUNIT_TEST( Traverse );
|
||||||
|
CPPUNIT_TEST( Enum );
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
void DirExists();
|
||||||
|
void Traverse();
|
||||||
|
void Enum();
|
||||||
|
|
||||||
|
void CreateTempFile(const wxString& path);
|
||||||
|
wxArrayString DirEnumHelper(wxDir& dir,
|
||||||
|
int flags = wxDIR_DEFAULT,
|
||||||
|
const wxString& filespec = wxEmptyString);
|
||||||
|
|
||||||
|
wxDECLARE_NO_COPY_CLASS(DirTestCase);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// CppUnit macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( DirTestCase );
|
||||||
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DirTestCase, "DirTestCase" );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// tests implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void DirTestCase::CreateTempFile(const wxString& path)
|
||||||
|
{
|
||||||
|
wxFile f(path, wxFile::write);
|
||||||
|
f.Write("dummy test file");
|
||||||
|
f.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirTestCase::setUp()
|
||||||
|
{
|
||||||
|
// create a test directory hierarchy
|
||||||
|
wxDir::Make(DIRTEST_FOLDER + SEP + "folder1" + SEP + "subfolder1", wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
||||||
|
wxDir::Make(DIRTEST_FOLDER + SEP + "folder1" + SEP + "subfolder2", wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
||||||
|
wxDir::Make(DIRTEST_FOLDER + SEP + "folder2", wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
||||||
|
wxDir::Make(DIRTEST_FOLDER + SEP + "folder3" + SEP + "subfolder1", wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
||||||
|
|
||||||
|
CreateTempFile(DIRTEST_FOLDER + SEP + "folder1" + SEP + "subfolder2" + SEP + "dummy");
|
||||||
|
CreateTempFile(DIRTEST_FOLDER + SEP + "dummy");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirTestCase::tearDown()
|
||||||
|
{
|
||||||
|
wxRemove(DIRTEST_FOLDER + SEP + "folder1" + SEP + "subfolder2" + SEP + "dummy");
|
||||||
|
wxRemove(DIRTEST_FOLDER + SEP + "dummy");
|
||||||
|
wxDir::Remove(DIRTEST_FOLDER, wxPATH_RMDIR_RECURSIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxArrayString DirTestCase::DirEnumHelper(wxDir& dir,
|
||||||
|
int flags,
|
||||||
|
const wxString& filespec)
|
||||||
|
{
|
||||||
|
wxArrayString ret;
|
||||||
|
CPPUNIT_ASSERT( dir.IsOpened() );
|
||||||
|
|
||||||
|
wxString filename;
|
||||||
|
bool cont = dir.GetFirst(&filename, filespec, flags);
|
||||||
|
while ( cont )
|
||||||
|
{
|
||||||
|
ret.push_back(filename);
|
||||||
|
cont = dir.GetNext(&filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirTestCase::Enum()
|
||||||
|
{
|
||||||
|
wxDir dir(DIRTEST_FOLDER);
|
||||||
|
CPPUNIT_ASSERT( dir.IsOpened() );
|
||||||
|
|
||||||
|
// enumerating everything in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(4, DirEnumHelper(dir).size());
|
||||||
|
|
||||||
|
// enumerating really everything in test directory recursively
|
||||||
|
CPPUNIT_ASSERT_EQUAL(6, DirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT).size());
|
||||||
|
|
||||||
|
// enumerating object files in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(0, DirEnumHelper(dir, wxDIR_DEFAULT, "*.o*").size());
|
||||||
|
|
||||||
|
// enumerating directories in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(3, DirEnumHelper(dir, wxDIR_DIRS).size());
|
||||||
|
|
||||||
|
// enumerating files in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(1, DirEnumHelper(dir, wxDIR_FILES).size());
|
||||||
|
|
||||||
|
// enumerating files including hidden in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(1, DirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN).size());
|
||||||
|
|
||||||
|
// enumerating files and folders in test directory
|
||||||
|
CPPUNIT_ASSERT_EQUAL(4, DirEnumHelper(dir, wxDIR_FILES | wxDIR_DIRS).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestDirTraverser : public wxDirTraverser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxArrayString dirs;
|
||||||
|
|
||||||
|
virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
|
||||||
|
{
|
||||||
|
return wxDIR_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxDirTraverseResult OnDir(const wxString& dirname)
|
||||||
|
{
|
||||||
|
dirs.push_back(dirname);
|
||||||
|
return wxDIR_CONTINUE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void DirTestCase::Traverse()
|
||||||
|
{
|
||||||
|
// enum all files
|
||||||
|
wxArrayString files;
|
||||||
|
CPPUNIT_ASSERT_EQUAL(2, wxDir::GetAllFiles(DIRTEST_FOLDER, &files));
|
||||||
|
|
||||||
|
// enum again with custom traverser
|
||||||
|
wxDir dir(DIRTEST_FOLDER);
|
||||||
|
TestDirTraverser traverser;
|
||||||
|
dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(6, traverser.dirs.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirTestCase::DirExists()
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const char *dirname;
|
||||||
|
bool shouldExist;
|
||||||
|
} testData[] =
|
||||||
|
{
|
||||||
|
{ ".", true },
|
||||||
|
{ "..", true },
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
{ "..\\..", true },
|
||||||
|
{ "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..", /*false*/ true },
|
||||||
|
// FIXME: should fail but it doesn't... looks like a bug in GetFileAttributes() win API
|
||||||
|
{ "c:", true },
|
||||||
|
{ "c:\\", true },
|
||||||
|
{ "c:\\\\", true },
|
||||||
|
{ "\\\\share\\file", false },
|
||||||
|
{ "c:\\a\\directory\\which\\does\\not\\exist", false },
|
||||||
|
{ "c:\\a\\directory\\which\\does\\not\\exist\\", false },
|
||||||
|
{ "c:\\a\\directory\\which\\does\\not\\exist\\\\", false },
|
||||||
|
{ "test.exe", false } // not a directory!
|
||||||
|
#elif defined(__UNIX__)
|
||||||
|
{ "../..", true },
|
||||||
|
{ "../../../../../../../../../../../../../../../../../../../..", false },
|
||||||
|
{ "/", true },
|
||||||
|
{ "//", true },
|
||||||
|
{ "/usr/bin", true },
|
||||||
|
{ "/usr//bin", false },
|
||||||
|
{ "/usr///bin", false }
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < WXSIZEOF(testData); n++ )
|
||||||
|
{
|
||||||
|
wxString errDesc = wxString::Format("failed on directory '%s'", testData[n].dirname);
|
||||||
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc.ToStdString(), testData[n].shouldExist, wxDir::Exists(testData[n].dirname));
|
||||||
|
|
||||||
|
if (!testData[n].shouldExist)
|
||||||
|
{
|
||||||
|
wxDir d(testData[n].dirname);
|
||||||
|
CPPUNIT_ASSERT(!d.IsOpened());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT( wxDir::Exists(wxGetCwd()) );
|
||||||
|
}
|
||||||
|
|
@@ -53,6 +53,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_stopwatch.obj \
|
$(OBJS)\test_stopwatch.obj \
|
||||||
$(OBJS)\test_timertest.obj \
|
$(OBJS)\test_timertest.obj \
|
||||||
$(OBJS)\test_exec.obj \
|
$(OBJS)\test_exec.obj \
|
||||||
|
$(OBJS)\test_dir.obj \
|
||||||
$(OBJS)\test_filefn.obj \
|
$(OBJS)\test_filefn.obj \
|
||||||
$(OBJS)\test_filetest.obj \
|
$(OBJS)\test_filetest.obj \
|
||||||
$(OBJS)\test_filekind.obj \
|
$(OBJS)\test_filekind.obj \
|
||||||
@@ -452,6 +453,9 @@ $(OBJS)\test_timertest.obj: .\events\timertest.cpp
|
|||||||
$(OBJS)\test_exec.obj: .\exec\exec.cpp
|
$(OBJS)\test_exec.obj: .\exec\exec.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\exec\exec.cpp
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\exec\exec.cpp
|
||||||
|
|
||||||
|
$(OBJS)\test_dir.obj: .\file\dir.cpp
|
||||||
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\file\dir.cpp
|
||||||
|
|
||||||
$(OBJS)\test_filefn.obj: .\file\filefn.cpp
|
$(OBJS)\test_filefn.obj: .\file\filefn.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\file\filefn.cpp
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\file\filefn.cpp
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_stopwatch.o \
|
$(OBJS)\test_stopwatch.o \
|
||||||
$(OBJS)\test_timertest.o \
|
$(OBJS)\test_timertest.o \
|
||||||
$(OBJS)\test_exec.o \
|
$(OBJS)\test_exec.o \
|
||||||
|
$(OBJS)\test_dir.o \
|
||||||
$(OBJS)\test_filefn.o \
|
$(OBJS)\test_filefn.o \
|
||||||
$(OBJS)\test_filetest.o \
|
$(OBJS)\test_filetest.o \
|
||||||
$(OBJS)\test_filekind.o \
|
$(OBJS)\test_filekind.o \
|
||||||
@@ -433,6 +434,9 @@ $(OBJS)\test_timertest.o: ./events/timertest.cpp
|
|||||||
$(OBJS)\test_exec.o: ./exec/exec.cpp
|
$(OBJS)\test_exec.o: ./exec/exec.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_dir.o: ./file/dir.cpp
|
||||||
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
$(OBJS)\test_filefn.o: ./file/filefn.cpp
|
$(OBJS)\test_filefn.o: ./file/filefn.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_stopwatch.obj \
|
$(OBJS)\test_stopwatch.obj \
|
||||||
$(OBJS)\test_timertest.obj \
|
$(OBJS)\test_timertest.obj \
|
||||||
$(OBJS)\test_exec.obj \
|
$(OBJS)\test_exec.obj \
|
||||||
|
$(OBJS)\test_dir.obj \
|
||||||
$(OBJS)\test_filefn.obj \
|
$(OBJS)\test_filefn.obj \
|
||||||
$(OBJS)\test_filetest.obj \
|
$(OBJS)\test_filetest.obj \
|
||||||
$(OBJS)\test_filekind.obj \
|
$(OBJS)\test_filekind.obj \
|
||||||
@@ -578,6 +579,9 @@ $(OBJS)\test_timertest.obj: .\events\timertest.cpp
|
|||||||
$(OBJS)\test_exec.obj: .\exec\exec.cpp
|
$(OBJS)\test_exec.obj: .\exec\exec.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\exec\exec.cpp
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\exec\exec.cpp
|
||||||
|
|
||||||
|
$(OBJS)\test_dir.obj: .\file\dir.cpp
|
||||||
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\file\dir.cpp
|
||||||
|
|
||||||
$(OBJS)\test_filefn.obj: .\file\filefn.cpp
|
$(OBJS)\test_filefn.obj: .\file\filefn.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\file\filefn.cpp
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\file\filefn.cpp
|
||||||
|
|
||||||
|
@@ -283,6 +283,7 @@ TEST_OBJECTS = &
|
|||||||
$(OBJS)\test_stopwatch.obj &
|
$(OBJS)\test_stopwatch.obj &
|
||||||
$(OBJS)\test_timertest.obj &
|
$(OBJS)\test_timertest.obj &
|
||||||
$(OBJS)\test_exec.obj &
|
$(OBJS)\test_exec.obj &
|
||||||
|
$(OBJS)\test_dir.obj &
|
||||||
$(OBJS)\test_filefn.obj &
|
$(OBJS)\test_filefn.obj &
|
||||||
$(OBJS)\test_filetest.obj &
|
$(OBJS)\test_filetest.obj &
|
||||||
$(OBJS)\test_filekind.obj &
|
$(OBJS)\test_filekind.obj &
|
||||||
@@ -490,6 +491,9 @@ $(OBJS)\test_timertest.obj : .AUTODEPEND .\events\timertest.cpp
|
|||||||
$(OBJS)\test_exec.obj : .AUTODEPEND .\exec\exec.cpp
|
$(OBJS)\test_exec.obj : .AUTODEPEND .\exec\exec.cpp
|
||||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_dir.obj : .AUTODEPEND .\file\dir.cpp
|
||||||
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
$(OBJS)\test_filefn.obj : .AUTODEPEND .\file\filefn.cpp
|
$(OBJS)\test_filefn.obj : .AUTODEPEND .\file\filefn.cpp
|
||||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
events/stopwatch.cpp
|
events/stopwatch.cpp
|
||||||
events/timertest.cpp
|
events/timertest.cpp
|
||||||
exec/exec.cpp
|
exec/exec.cpp
|
||||||
|
file/dir.cpp
|
||||||
file/filefn.cpp
|
file/filefn.cpp
|
||||||
file/filetest.cpp
|
file/filetest.cpp
|
||||||
filekind/filekind.cpp
|
filekind/filekind.cpp
|
||||||
|
@@ -279,6 +279,10 @@ SOURCE=.\datetime\datetimetest.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\file\dir.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\dummy.cpp
|
SOURCE=.\dummy.cpp
|
||||||
# ADD BASE CPP /Yc"testprec.h"
|
# ADD BASE CPP /Yc"testprec.h"
|
||||||
# ADD CPP /Yc"testprec.h"
|
# ADD CPP /Yc"testprec.h"
|
||||||
|
@@ -598,6 +598,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\datetime\datetimetest.cpp">
|
RelativePath=".\datetime\datetimetest.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\file\dir.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dummy.cpp">
|
RelativePath=".\dummy.cpp">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
|
@@ -871,6 +871,10 @@
|
|||||||
RelativePath=".\datetime\datetimetest.cpp"
|
RelativePath=".\datetime\datetimetest.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\file\dir.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dummy.cpp"
|
RelativePath=".\dummy.cpp"
|
||||||
>
|
>
|
||||||
|
@@ -843,6 +843,10 @@
|
|||||||
RelativePath=".\datetime\datetimetest.cpp"
|
RelativePath=".\datetime\datetimetest.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\file\dir.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dummy.cpp"
|
RelativePath=".\dummy.cpp"
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user