for for initializing wxFileName with empty string returning true from IsOk() and tests for the correct behaviour (patch 1617156)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-16 23:11:48 +00:00
parent 779e158bb2
commit 698581160d
2 changed files with 24 additions and 1 deletions

View File

@@ -427,7 +427,7 @@ void wxFileName::Assign(const wxString& fullpathOrig,
// always recognize fullpath as directory, even if it doesn't end with a // always recognize fullpath as directory, even if it doesn't end with a
// slash // slash
wxString fullpath = fullpathOrig; wxString fullpath = fullpathOrig;
if ( !wxEndsWithPathSeparator(fullpath) ) if ( !fullpath.empty() && !wxEndsWithPathSeparator(fullpath) )
{ {
fullpath += GetPathSeparator(format); fullpath += GetPathSeparator(format);
} }

View File

@@ -49,6 +49,11 @@ static struct FileNameInfo
wxPathFormat format; wxPathFormat format;
} filenames[] = } filenames[] =
{ {
// the empty string
{ _T(""), _(""), _(""), _(""), _(""), false, wxPATH_UNIX },
{ _T(""), _(""), _(""), _(""), _(""), false, wxPATH_DOS },
{ _T(""), _(""), _(""), _(""), _(""), false, wxPATH_VMS },
// Unix file names // Unix file names
{ _T("/usr/bin/ls"), _T(""), _T("/usr/bin"), _T("ls"), _T(""), true, wxPATH_UNIX }, { _T("/usr/bin/ls"), _T(""), _T("/usr/bin"), _T("ls"), _T(""), true, wxPATH_UNIX },
{ _T("/usr/bin/"), _T(""), _T("/usr/bin"), _T(""), _T(""), true, wxPATH_UNIX }, { _T("/usr/bin/"), _T(""), _T("/usr/bin"), _T(""), _T(""), true, wxPATH_UNIX },
@@ -167,6 +172,24 @@ void FileNameTestCase::TestConstruction()
fni.format), fn ); fni.format), fn );
} }
} }
wxFileName fn;
// empty strings
fn.AssignDir(wxEmptyString);
CPPUNIT_ASSERT( !fn.IsOk() );
fn.Assign(wxEmptyString);
CPPUNIT_ASSERT( !fn.IsOk() );
fn.Assign(wxEmptyString, wxEmptyString);
CPPUNIT_ASSERT( !fn.IsOk() );
fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString);
CPPUNIT_ASSERT( !fn.IsOk() );
fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString);
CPPUNIT_ASSERT( !fn.IsOk() );
} }
void FileNameTestCase::TestComparison() void FileNameTestCase::TestComparison()