]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/console/console.cpp
fixed typos in Unicode configs of wxBase (thanks Dimitri)
[wxWidgets.git] / samples / console / console.cpp
index 47c1c3f8abc39912f4d0004ffdf1d4e91dba4b44..f155e4b05094370a19b2a62eef53733106ee2b8b 100644 (file)
@@ -83,6 +83,7 @@
     #define TEST_THREADS
     #define TEST_TIMER
     // #define TEST_VCARD            -- don't enable this (VZ)
+    #define TEST_VOLUME
     #define TEST_WCHAR
     #define TEST_ZIP
     #define TEST_ZLIB
@@ -90,7 +91,7 @@
     #undef TEST_ALL
     static const bool TEST_ALL = TRUE;
 #else
-    #define TEST_WCHAR
+    #define TEST_FILENAME
 
     static const bool TEST_ALL = FALSE;
 #endif
@@ -801,6 +802,8 @@ static struct FileNameInfo
     { _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), TRUE, wxPATH_DOS },
     { _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
 
+    // wxFileName support for Mac file names is broken crurently
+#if 0
     // Mac file names
     { _T("Volume:Dir:File"), _T("Volume"), _T("Dir"), _T("File"), _T(""), TRUE, wxPATH_MAC },
     { _T("Volume:Dir:Subdir:File"), _T("Volume"), _T("Dir:Subdir"), _T("File"), _T(""), TRUE, wxPATH_MAC },
@@ -808,6 +811,7 @@ static struct FileNameInfo
     { _T(":Dir:File"), _T(""), _T("Dir"), _T("File"), _T(""), FALSE, wxPATH_MAC },
     { _T(":File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), FALSE, wxPATH_MAC },
     { _T("File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), FALSE, wxPATH_MAC },
+#endif // 0
 
     // VMS file names
     { _T("device:[dir1.dir2.dir3]file.txt"), _T("device"), _T("dir1.dir2.dir3"), _T("file"), _T("txt"), TRUE, wxPATH_VMS },
@@ -830,7 +834,7 @@ static void TestFileNameConstruction()
             printf("ERROR: fullname should be '%s'\n", fni.fullname);
         }
 
-        bool isAbsolute = fn.IsAbsolute();
+        bool isAbsolute = fn.IsAbsolute(fni.format);
         printf("'%s' is %s (%s)\n\t",
                fullname.c_str(),
                isAbsolute ? "absolute" : "relative",
@@ -883,11 +887,14 @@ static void TestFileNameTemp()
 
     static const char *tmpprefixes[] =
     {
+        "",
         "foo",
-        "/tmp/foo",
         "..",
         "../bar",
+#ifdef __UNIX__
+        "/tmp/foo",
         "/tmp/foo/bar", // this one must be an error
+#endif // __UNIX__
     };
 
     for ( size_t n = 0; n < WXSIZEOF(tmpprefixes); n++ )
@@ -982,8 +989,8 @@ static void TestFileGetTimes()
 {
     wxFileName fn(_T("testdata.fc"));
 
-    wxDateTime dtAccess, dtMod, dtChange;
-    if ( !fn.GetTimes(&dtAccess, &dtMod, &dtChange) )
+    wxDateTime dtAccess, dtMod, dtCreate;
+    if ( !fn.GetTimes(&dtAccess, &dtMod, &dtCreate) )
     {
         wxPrintf(_T("ERROR: GetTimes() failed.\n"));
     }
@@ -992,9 +999,9 @@ static void TestFileGetTimes()
         static const wxChar *fmt = _T("%Y-%b-%d %H:%M:%S");
 
         wxPrintf(_T("File times for '%s':\n"), fn.GetFullPath().c_str());
-        wxPrintf(_T("Access:      \t%s\n"), dtAccess.Format(fmt).c_str());
-        wxPrintf(_T("Mod/creation:\t%s\n"), dtMod.Format(fmt).c_str());
-        wxPrintf(_T("Change:      \t%s\n"), dtChange.Format(fmt).c_str());
+        wxPrintf(_T("Creation:    \t%s\n"), dtCreate.Format(fmt).c_str());
+        wxPrintf(_T("Last read:   \t%s\n"), dtAccess.Format(fmt).c_str());
+        wxPrintf(_T("Last write:  \t%s\n"), dtMod.Format(fmt).c_str());
     }
 }
 
@@ -3298,6 +3305,65 @@ static void TestVCardWrite()
 
 #endif // TEST_VCARD
 
+// ----------------------------------------------------------------------------
+// wxVolume tests
+// ----------------------------------------------------------------------------
+
+#if !wxUSE_FSVOLUME
+    #undef TEST_VOLUME
+#endif
+
+#ifdef TEST_VOLUME
+
+#include "wx/volume.h"
+
+static const wxChar *volumeKinds[] =
+{
+    _T("floppy"),
+    _T("hard disk"),
+    _T("CD-ROM"),
+    _T("DVD-ROM"),
+    _T("network volume"),
+    _T("other volume"),
+};
+
+static void TestFSVolume()
+{
+    wxPuts(_T("*** Testing wxFSVolume class ***"));
+
+    wxArrayString volumes = wxFSVolume::GetVolumes();
+    size_t count = volumes.GetCount();
+
+    if ( !count )
+    {
+        wxPuts(_T("ERROR: no mounted volumes?"));
+        return;
+    }
+
+    wxPrintf(_T("%u mounted volumes found:\n"), count);
+
+    for ( size_t n = 0; n < count; n++ )
+    {
+        wxFSVolume vol(volumes[n]);
+        if ( !vol.IsOk() )
+        {
+            wxPuts(_T("ERROR: couldn't create volume"));
+            continue;
+        }
+
+        wxPrintf(_T("%u: %s (%s), %s, %s, %s\n"),
+                 n + 1,
+                 vol.GetDisplayName().c_str(),
+                 vol.GetName().c_str(),
+                 volumeKinds[vol.GetKind()],
+                 vol.IsWritable() ? _T("rw") : _T("ro"),
+                 vol.GetFlags() & wxFS_VOL_REMOVABLE ? _T("removable")
+                                                     : _T("fixed"));
+    }
+}
+
+#endif // TEST_VOLUME
+
 // ----------------------------------------------------------------------------
 // wide char (Unicode) support
 // ----------------------------------------------------------------------------
@@ -5633,7 +5699,7 @@ int main(int argc, char **argv)
 #endif // TEST_FILE
 
 #ifdef TEST_FILENAME
-    if ( 1 )
+    if ( 0 )
     {
         wxFileName fn;
         fn.Assign("c:\\foo", "bar.baz");
@@ -5641,7 +5707,7 @@ int main(int argc, char **argv)
         DumpFileName(fn);
     }
 
-    if ( TEST_ALL )
+    if ( 1 )
     {
         TestFileNameConstruction();
         TestFileNameMakeRelative();
@@ -5830,6 +5896,10 @@ int main(int argc, char **argv)
     TestVCardWrite();
 #endif // TEST_VCARD
 
+#ifdef TEST_VOLUME
+    TestFSVolume();
+#endif // TEST_VOLUME
+
 #ifdef TEST_WCHAR
     TestUtf8();
     TestEncodingConverter();