]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/console/console.cpp
Updates to fix EMX specific stuff that broke VisualAge specific stuff
[wxWidgets.git] / samples / console / console.cpp
index e3c75ec71d2de895f2eef872ffcd01c6988b943a..80d7eb5be058f252bd2a154889ed667ac28ca4d1 100644 (file)
 //#define TEST_ARRAYS
 //#define TEST_CMDLINE
 //#define TEST_DIR
+#define TEST_EXECUTE
 //#define TEST_LOG
 //#define TEST_LONGLONG
 //#define TEST_MIME
 //#define TEST_STRINGS
 //#define TEST_THREADS
-#define TEST_TIME
+//#define TEST_TIME
 
 // ============================================================================
 // implementation
@@ -160,6 +161,34 @@ static void TestDirEnum()
 
 #endif // TEST_DIR
 
+// ----------------------------------------------------------------------------
+// wxExecute
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_EXECUTE
+
+#include <wx/utils.h>
+
+static void TestExecute()
+{
+    puts("*** testing wxExecute ***");
+
+#ifdef __UNIX__
+    #define COMMAND "echo hi"
+#elif defined(__WXMSW__)
+    #define COMMAND "command.com -c 'echo hi'"
+#else
+    #error "no command to exec"
+#endif // OS
+
+    if ( wxExecute(COMMAND) == 0 )
+        puts("\nOk.");
+    else
+        puts("\nError.");
+}
+
+#endif // TEST_EXECUTE
+
 // ----------------------------------------------------------------------------
 // MIME types
 // ----------------------------------------------------------------------------
@@ -1349,6 +1378,31 @@ static void TestTimeArithmetics()
     }
 }
 
+static void TestTimeHolidays()
+{
+    puts("\n*** testing wxDateTimeHolidayAuthority ***\n");
+
+    wxDateTime::Tm tm = wxDateTime(29, wxDateTime::May, 2000).GetTm();
+    wxDateTime dtStart(1, tm.mon, tm.year),
+               dtEnd = dtStart.GetLastMonthDay();
+
+    wxDateTimeArray hol;
+    wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol);
+
+    const wxChar *format = "%d-%b-%Y (%a)";
+
+    printf("All holidays between %s and %s:\n",
+           dtStart.Format(format).c_str(), dtEnd.Format(format).c_str());
+
+    size_t count = hol.GetCount();
+    for ( size_t n = 0; n < count; n++ )
+    {
+        printf("\t%s\n", hol[n].Format(format).c_str());
+    }
+
+    puts("");
+}
+
 #if 0
 
 // test compatibility with the old wxDate/wxTime classes
@@ -1737,6 +1791,11 @@ int main(int argc, char **argv)
         fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
     }
 
+#ifdef TEST_USLEEP
+    puts("Sleeping for 3 seconds... z-z-z-z-z...");
+    wxUsleep(3000);
+#endif // TEST_USLEEP
+
 #ifdef TEST_CMDLINE
     static const wxCmdLineEntryDesc cmdLineDesc[] =
     {
@@ -1821,6 +1880,10 @@ int main(int argc, char **argv)
     TestDirEnum();
 #endif // TEST_DIR
 
+#ifdef TEST_EXECUTE
+    TestExecute();
+#endif // TEST_EXECUTE
+
 #ifdef TEST_LOG
     wxString s;
     for ( size_t n = 0; n < 8000; n++ )
@@ -1883,7 +1946,7 @@ int main(int argc, char **argv)
 #endif // TEST_MIME
 
 #ifdef TEST_TIME
-    if ( 1 )
+    if ( 0 )
     {
         TestTimeSet();
         TestTimeStatic();
@@ -1898,6 +1961,7 @@ int main(int argc, char **argv)
         TestTimeFormat();
         TestTimeArithmetics();
     }
+    TestTimeHolidays();
     if ( 0 )
         TestInteractive();
 #endif // TEST_TIME