]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/console/console.cpp
no, we shouldn't inconditionally add the separator at the end even if wxPATH_GET_SEPA...
[wxWidgets.git] / samples / console / console.cpp
index 0bca4581a549253507e798bc68fed4e49fb5fb3d..5a8015c7857113d4192083a2da46b2737232ccb1 100644 (file)
@@ -91,7 +91,7 @@
     #undef TEST_ALL
     static const bool TEST_ALL = TRUE;
 #else
-    #define TEST_ARRAYS
+    #define TEST_DIR
 
     static const bool TEST_ALL = FALSE;
 #endif
@@ -307,7 +307,19 @@ static void TestDirEnum()
 {
     puts("*** Testing wxDir::GetFirst/GetNext ***");
 
-    wxDir dir(wxGetCwd());
+    wxString cwd = wxGetCwd();
+    if ( wxDir::Exists(cwd) )
+    {
+        printf("ERROR: current directory '%s' doesn't exist?\n", cwd.c_str());
+        return;
+    }
+
+    wxDir dir(cwd);
+    if ( !dir.IsOpened() )
+    {
+        printf("ERROR: failed to open current directory '%s'.\n", cwd.c_str());
+        return;
+    }
 
     puts("Enumerating everything in current directory:");
     TestDirEnumHelper(dir);
@@ -395,6 +407,38 @@ static void TestDirTraverse()
     dir.Traverse(traverser, _T(""), wxDIR_DIRS | wxDIR_HIDDEN);
 }
 
+static void TestDirExists()
+{
+    wxPuts(_T("*** Testing wxDir::Exists() ***"));
+
+    static const char *dirnames[] =
+    {
+        _T("."),
+#if defined(__WXMSW__)
+        _T("c:"),
+        _T("c:\\"),
+        _T("\\\\share\\file"),
+        _T("c:\\dos"),
+        _T("c:\\dos\\"),
+        _T("c:\\dos\\\\"),
+        _T("c:\\autoexec.bat"),
+#elif defined(__UNIX__)
+        _T("/"),
+        _T("//"),
+        _T("/usr/bin"),
+        _T("/usr//bin"),
+        _T("/usr///bin"),
+#endif
+    };
+
+    for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
+    {
+        printf(_T("%-40s: %s\n"),
+               dirnames[n],
+               wxDir::Exists(dirnames[n]) ? _T("exists") : _T("doesn't exist"));
+    }
+}
+
 #endif // TEST_DIR
 
 // ----------------------------------------------------------------------------
@@ -3581,16 +3625,16 @@ static void TestZipFileSystem()
 #include "wx/wfstream.h"
 
 static const wxChar *FILENAME_GZ = _T("test.gz");
-static const char *TEST_DATA = "hello and hello again";
+static const char *TEST_DATA = "hello and hello and hello and hello and hello";
 
 static void TestZlibStreamWrite()
 {
     puts("*** Testing Zlib stream reading ***\n");
 
     wxFileOutputStream fileOutStream(FILENAME_GZ);
-    wxZlibOutputStream ostr(fileOutStream, 0);
+    wxZlibOutputStream ostr(fileOutStream);
     printf("Compressing the test string... ");
-    ostr.Write(TEST_DATA, sizeof(TEST_DATA));
+    ostr.Write(TEST_DATA, strlen(TEST_DATA) + 1);
     if ( !ostr )
     {
         puts("(ERROR: failed)");
@@ -5791,6 +5835,7 @@ int main(int argc, char **argv)
 #endif // TEST_ARRAYS
 
 #ifdef TEST_DIR
+    TestDirExists();
     if ( TEST_ALL )
     {
         TestDirEnum();