]> git.saurik.com Git - wxWidgets.git/commitdiff
for for initializing wxFileName with empty string returning true from IsOk() and...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Dec 2006 23:11:48 +0000 (23:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Dec 2006 23:11:48 +0000 (23:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/filename.cpp
tests/filename/filenametest.cpp

index 234ac801380c964f309a0d55bb62e051da451650..99f24f2e1623df970764697b5a332dfcf01a7055 100644 (file)
@@ -427,7 +427,7 @@ void wxFileName::Assign(const wxString& fullpathOrig,
     // always recognize fullpath as directory, even if it doesn't end with a
     // slash
     wxString fullpath = fullpathOrig;
-    if ( !wxEndsWithPathSeparator(fullpath) )
+    if ( !fullpath.empty() && !wxEndsWithPathSeparator(fullpath) )
     {
         fullpath += GetPathSeparator(format);
     }
index 992a05a8bfa42fe9a28809832f8325d49d3371a4..813079ca8e54de2e9d1096401c280a7eb8bbff12 100644 (file)
@@ -49,6 +49,11 @@ static struct FileNameInfo
     wxPathFormat format;
 } filenames[] =
 {
+    // the empty string
+    { _T(""), _(""), _(""), _(""), _(""), false, wxPATH_UNIX }, 
+    { _T(""), _(""), _(""), _(""), _(""), false, wxPATH_DOS }, 
+    { _T(""), _(""), _(""), _(""), _(""), false, wxPATH_VMS }, 
+
     // Unix file names
     { _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 },
@@ -167,6 +172,24 @@ void FileNameTestCase::TestConstruction()
                                              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()