fixed wxSplitPath() bug and added tests for it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -37,14 +37,14 @@
 | 
			
		||||
 | 
			
		||||
//#define TEST_ARRAYS
 | 
			
		||||
//#define TEST_CMDLINE
 | 
			
		||||
#define TEST_DATETIME
 | 
			
		||||
//#define TEST_DATETIME
 | 
			
		||||
//#define TEST_DIR
 | 
			
		||||
//#define TEST_DLLLOADER
 | 
			
		||||
//#define TEST_ENVIRON
 | 
			
		||||
//#define TEST_EXECUTE
 | 
			
		||||
//#define TEST_FILE
 | 
			
		||||
//#define TEST_FILECONF
 | 
			
		||||
//#define TEST_FILENAME
 | 
			
		||||
#define TEST_FILENAME
 | 
			
		||||
//#define TEST_FTP
 | 
			
		||||
//#define TEST_HASH
 | 
			
		||||
//#define TEST_LIST
 | 
			
		||||
@@ -596,18 +596,20 @@ static void TestFileConfRead()
 | 
			
		||||
 | 
			
		||||
#include <wx/filename.h>
 | 
			
		||||
 | 
			
		||||
static const wxChar *filenames[] =
 | 
			
		||||
{
 | 
			
		||||
    _T("/usr/bin/ls"),
 | 
			
		||||
    _T("/usr/bin/"),
 | 
			
		||||
    _T("~/.zshrc"),
 | 
			
		||||
    _T("../../foo"),
 | 
			
		||||
    _T("~/foo.bar"),
 | 
			
		||||
    _T("/tmp/wxwin.tar.bz"),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void TestFileNameConstruction()
 | 
			
		||||
{
 | 
			
		||||
    puts("*** testing wxFileName construction ***");
 | 
			
		||||
 | 
			
		||||
    static const wxChar *filenames[] =
 | 
			
		||||
    {
 | 
			
		||||
        _T("/usr/bin/ls"),
 | 
			
		||||
        _T("/usr/bin/"),
 | 
			
		||||
        _T("~/.zshrc"),
 | 
			
		||||
        _T("../../foo"),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
 | 
			
		||||
    {
 | 
			
		||||
        wxFileName fn(filenames[n], wxPATH_UNIX);
 | 
			
		||||
@@ -626,6 +628,21 @@ static void TestFileNameConstruction()
 | 
			
		||||
    puts("");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void TestFileNameSplit()
 | 
			
		||||
{
 | 
			
		||||
    puts("*** testing wxFileName splitting ***");
 | 
			
		||||
 | 
			
		||||
    for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
 | 
			
		||||
    {
 | 
			
		||||
        wxString path, name, ext;
 | 
			
		||||
        wxFileName::SplitPath(filenames[n], &path, &name, &ext);
 | 
			
		||||
        printf("%s -> path = '%s', name = '%s', ext = '%s'\n",
 | 
			
		||||
               filenames[n], path.c_str(), name.c_str(), ext.c_str());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    puts("");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void TestFileNameComparison()
 | 
			
		||||
{
 | 
			
		||||
    // TODO!
 | 
			
		||||
@@ -4000,9 +4017,10 @@ int main(int argc, char **argv)
 | 
			
		||||
#endif // TEST_FILE
 | 
			
		||||
 | 
			
		||||
#ifdef TEST_FILENAME
 | 
			
		||||
    TestFileNameConstruction();
 | 
			
		||||
    TestFileNameSplit();
 | 
			
		||||
    if ( 0 )
 | 
			
		||||
    {
 | 
			
		||||
        TestFileNameConstruction();
 | 
			
		||||
        TestFileNameCwd();
 | 
			
		||||
        TestFileNameComparison();
 | 
			
		||||
        TestFileNameOperations();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user