1999-10-06 17:48:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: samples/console/console.cpp
|
|
|
|
// Purpose: a sample console (as opposed to GUI) progam using wxWindows
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04.10.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-06 17:48:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <wx/string.h>
|
1999-10-07 18:12:57 +00:00
|
|
|
#include <wx/file.h>
|
1999-10-06 17:48:34 +00:00
|
|
|
#include <wx/app.h>
|
1999-10-22 09:24:15 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// conditional compilation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// what to test?
|
1999-11-15 15:49:59 +00:00
|
|
|
|
|
|
|
//#define TEST_ARRAYS
|
1999-11-27 22:57:06 +00:00
|
|
|
//#define TEST_LOG
|
1999-11-29 23:05:23 +00:00
|
|
|
//#define TEST_STRINGS
|
1999-11-30 21:55:00 +00:00
|
|
|
//#define TEST_THREADS
|
|
|
|
#define TEST_TIME
|
1999-11-29 23:05:23 +00:00
|
|
|
//#define TEST_LONGLONG
|
1999-10-22 09:24:15 +00:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
1999-11-28 23:30:18 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// long long
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef TEST_LONGLONG
|
|
|
|
|
|
|
|
#include <wx/longlong.h>
|
|
|
|
#include <wx/timer.h>
|
|
|
|
|
|
|
|
static void TestSpeed()
|
|
|
|
{
|
|
|
|
static const long max = 100000000;
|
|
|
|
long n;
|
1999-11-29 23:05:23 +00:00
|
|
|
|
1999-11-28 23:30:18 +00:00
|
|
|
{
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
long l = 0;
|
|
|
|
for ( n = 0; n < max; n++ )
|
|
|
|
{
|
|
|
|
l += n;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Summing longs took %ld milliseconds.\n", sw.Time());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
__int64 l = 0;
|
|
|
|
for ( n = 0; n < max; n++ )
|
|
|
|
{
|
|
|
|
l += n;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Summing __int64s took %ld milliseconds.\n", sw.Time());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
wxLongLong l;
|
|
|
|
for ( n = 0; n < max; n++ )
|
|
|
|
{
|
|
|
|
l += n;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Summing wxLongLongs took %ld milliseconds.\n", sw.Time());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TestDivision()
|
|
|
|
{
|
1999-11-30 21:55:00 +00:00
|
|
|
#define MAKE_LL(x1, x2, x3, x4) wxLongLong((x1 << 16) | x2, (x3 << 16) | x3)
|
1999-11-28 23:30:18 +00:00
|
|
|
|
1999-11-30 21:55:00 +00:00
|
|
|
// seed pseudo random generator
|
|
|
|
//srand((unsigned)time(NULL));
|
|
|
|
|
|
|
|
size_t nTested = 0;
|
|
|
|
for ( size_t n = 0; n < 10000; n++ )
|
|
|
|
{
|
|
|
|
// get a random wxLongLong (shifting by 12 the MSB ensures that the
|
|
|
|
// multiplication will not overflow)
|
|
|
|
wxLongLong ll = MAKE_LL((rand() >> 12), rand(), rand(), rand());
|
|
|
|
|
|
|
|
wxASSERT( (ll * 1000l)/1000l == ll );
|
|
|
|
|
|
|
|
nTested++;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n*** Tested %u divisions/multiplications: ok\n", nTested);
|
|
|
|
|
|
|
|
#undef MAKE_LL
|
1999-11-28 23:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TEST_LONGLONG
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// date time
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef TEST_TIME
|
|
|
|
|
|
|
|
#include <wx/datetime.h>
|
|
|
|
|
1999-11-30 21:55:00 +00:00
|
|
|
// this test miscellaneous static wxDateTime functions
|
|
|
|
static void TestTimeStatic()
|
|
|
|
{
|
|
|
|
puts("\n*** wxDateTime static methods test ***");
|
|
|
|
|
|
|
|
// some info about the current date
|
|
|
|
int year = wxDateTime::GetCurrentYear();
|
|
|
|
printf("Current year %d is %sa leap one and has %d days.\n",
|
|
|
|
year,
|
|
|
|
wxDateTime::IsLeapYear(year) ? "" : "not ",
|
|
|
|
wxDateTime::GetNumberOfDays(year));
|
|
|
|
|
|
|
|
wxDateTime::Month month = wxDateTime::GetCurrentMonth();
|
|
|
|
printf("Current month is '%s' ('%s') and it has %d days\n",
|
|
|
|
wxDateTime::GetMonthName(month, TRUE).c_str(),
|
|
|
|
wxDateTime::GetMonthName(month).c_str(),
|
|
|
|
wxDateTime::GetNumberOfDays(month));
|
|
|
|
|
|
|
|
// leap year logic
|
|
|
|
static const nYears = 5;
|
|
|
|
static const int years[2][nYears] =
|
|
|
|
{
|
|
|
|
// first line: the years to test
|
|
|
|
{ 1990, 1976, 2000, 2030, 1984, },
|
|
|
|
|
|
|
|
// second line: TRUE if leap, FALSE otherwise
|
|
|
|
{ FALSE, TRUE, TRUE, FALSE, TRUE }
|
|
|
|
};
|
|
|
|
|
|
|
|
for ( size_t n = 0; n < nYears; n++ )
|
|
|
|
{
|
|
|
|
int year = years[0][n];
|
|
|
|
bool should = years[1][n] != 0;
|
|
|
|
|
|
|
|
printf("Year %d is %sa leap year (should be: %s)\n",
|
|
|
|
year,
|
|
|
|
wxDateTime::IsLeapYear(year) ? "" : "not ",
|
|
|
|
should ? "yes" : "no");
|
|
|
|
|
|
|
|
wxASSERT( should == wxDateTime::IsLeapYear(year) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// test constructing wxDateTime objects
|
|
|
|
static void TestTimeSet()
|
|
|
|
{
|
|
|
|
puts("\n*** wxDateTime construction test ***");
|
|
|
|
|
|
|
|
printf("Current time:\t%s\n", wxDateTime::Now().Format().c_str());
|
|
|
|
printf("Unix epoch:\t%s\n", wxDateTime((time_t)0).Format().c_str());
|
|
|
|
printf("Today noon:\t%s\n", wxDateTime(12, 0).Format().c_str());
|
|
|
|
printf("May 29, 1976:\t%s\n", wxDateTime(29, wxDateTime::May, 1976).Format().c_str());
|
|
|
|
}
|
|
|
|
|
1999-11-28 23:30:18 +00:00
|
|
|
#endif // TEST_TIME
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// threads
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef TEST_THREADS
|
|
|
|
|
1999-10-07 18:12:57 +00:00
|
|
|
#include <wx/thread.h>
|
1999-10-06 17:48:34 +00:00
|
|
|
|
1999-10-07 18:12:57 +00:00
|
|
|
static size_t gs_counter = (size_t)-1;
|
|
|
|
static wxCriticalSection gs_critsect;
|
1999-11-27 22:57:06 +00:00
|
|
|
static wxCondition gs_cond;
|
1999-10-07 18:12:57 +00:00
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
class MyJoinableThread : public wxThread
|
1999-10-07 18:12:57 +00:00
|
|
|
{
|
|
|
|
public:
|
1999-11-27 22:57:06 +00:00
|
|
|
MyJoinableThread(size_t n) : wxThread(wxTHREAD_JOINABLE)
|
|
|
|
{ m_n = n; Create(); }
|
1999-10-07 18:12:57 +00:00
|
|
|
|
|
|
|
// thread execution starts here
|
1999-11-27 22:57:06 +00:00
|
|
|
virtual ExitCode Entry();
|
1999-10-07 18:12:57 +00:00
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
private:
|
|
|
|
size_t m_n;
|
1999-10-07 18:12:57 +00:00
|
|
|
};
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
wxThread::ExitCode MyJoinableThread::Entry()
|
1999-10-07 18:12:57 +00:00
|
|
|
{
|
1999-11-27 22:57:06 +00:00
|
|
|
unsigned long res = 1;
|
|
|
|
for ( size_t n = 1; n < m_n; n++ )
|
|
|
|
{
|
|
|
|
res *= n;
|
|
|
|
|
|
|
|
// it's a loooong calculation :-)
|
|
|
|
Sleep(100);
|
|
|
|
}
|
1999-10-07 18:12:57 +00:00
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
return (ExitCode)res;
|
1999-10-07 18:12:57 +00:00
|
|
|
}
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
class MyDetachedThread : public wxThread
|
|
|
|
{
|
|
|
|
public:
|
1999-11-29 23:05:23 +00:00
|
|
|
MyDetachedThread(size_t n, char ch) { m_n = n; m_ch = ch; Create(); }
|
1999-11-27 22:57:06 +00:00
|
|
|
|
|
|
|
// thread execution starts here
|
|
|
|
virtual ExitCode Entry();
|
|
|
|
|
|
|
|
// and stops here
|
|
|
|
virtual void OnExit();
|
|
|
|
|
|
|
|
private:
|
1999-11-29 23:05:23 +00:00
|
|
|
size_t m_n; // number of characters to write
|
|
|
|
char m_ch; // character to write
|
1999-11-27 22:57:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
wxThread::ExitCode MyDetachedThread::Entry()
|
1999-10-07 18:12:57 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
wxCriticalSectionLocker lock(gs_critsect);
|
|
|
|
if ( gs_counter == (size_t)-1 )
|
|
|
|
gs_counter = 1;
|
|
|
|
else
|
|
|
|
gs_counter++;
|
|
|
|
}
|
|
|
|
|
1999-11-29 23:05:23 +00:00
|
|
|
for ( size_t n = 0; n < m_n; n++ )
|
1999-10-07 18:12:57 +00:00
|
|
|
{
|
|
|
|
if ( TestDestroy() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
putchar(m_ch);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
wxThread::Sleep(100);
|
|
|
|
}
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
return 0;
|
1999-10-07 18:12:57 +00:00
|
|
|
}
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
void MyDetachedThread::OnExit()
|
1999-10-07 18:12:57 +00:00
|
|
|
{
|
1999-11-29 23:05:23 +00:00
|
|
|
wxLogTrace("thread", "Thread %ld is in OnExit", GetId());
|
|
|
|
|
1999-10-07 18:12:57 +00:00
|
|
|
wxCriticalSectionLocker lock(gs_critsect);
|
1999-11-27 22:57:06 +00:00
|
|
|
if ( !--gs_counter )
|
|
|
|
gs_cond.Signal();
|
1999-10-07 18:12:57 +00:00
|
|
|
}
|
|
|
|
|
1999-11-29 23:05:23 +00:00
|
|
|
void TestDetachedThreads()
|
|
|
|
{
|
1999-11-30 21:55:00 +00:00
|
|
|
puts("\n*** Testing detached threads ***");
|
1999-11-29 23:05:23 +00:00
|
|
|
|
|
|
|
static const size_t nThreads = 3;
|
|
|
|
MyDetachedThread *threads[nThreads];
|
|
|
|
size_t n;
|
|
|
|
for ( n = 0; n < nThreads; n++ )
|
|
|
|
{
|
|
|
|
threads[n] = new MyDetachedThread(10, 'A' + n);
|
|
|
|
}
|
|
|
|
|
|
|
|
threads[0]->SetPriority(WXTHREAD_MIN_PRIORITY);
|
|
|
|
threads[1]->SetPriority(WXTHREAD_MAX_PRIORITY);
|
|
|
|
|
|
|
|
for ( n = 0; n < nThreads; n++ )
|
|
|
|
{
|
|
|
|
threads[n]->Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait until all threads terminate
|
|
|
|
gs_cond.Wait();
|
|
|
|
|
|
|
|
puts("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestJoinableThreads()
|
|
|
|
{
|
1999-11-30 21:55:00 +00:00
|
|
|
puts("\n*** Testing a joinable thread (a loooong calculation...) ***");
|
1999-11-29 23:05:23 +00:00
|
|
|
|
|
|
|
// calc 10! in the background
|
|
|
|
MyJoinableThread thread(10);
|
|
|
|
thread.Run();
|
|
|
|
|
|
|
|
printf("\nThread terminated with exit code %lu.\n",
|
|
|
|
(unsigned long)thread.Wait());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestThreadSuspend()
|
|
|
|
{
|
1999-11-30 21:55:00 +00:00
|
|
|
puts("\n*** Testing thread suspend/resume functions ***");
|
|
|
|
|
|
|
|
MyDetachedThread *thread = new MyDetachedThread(15, 'X');
|
1999-11-29 23:05:23 +00:00
|
|
|
|
|
|
|
thread->Run();
|
|
|
|
|
|
|
|
// this is for this demo only, in a real life program we'd use another
|
|
|
|
// condition variable which would be signaled from wxThread::Entry() to
|
|
|
|
// tell us that the thread really started running - but here just wait a
|
|
|
|
// bit and hope that it will be enough (the problem is, of course, that
|
|
|
|
// the thread might still not run when we call Pause() which will result
|
|
|
|
// in an error)
|
|
|
|
wxThread::Sleep(300);
|
|
|
|
|
|
|
|
for ( size_t n = 0; n < 3; n++ )
|
|
|
|
{
|
|
|
|
thread->Pause();
|
|
|
|
|
|
|
|
puts("\nThread suspended");
|
|
|
|
if ( n > 0 )
|
|
|
|
{
|
|
|
|
// don't sleep but resume immediately the first time
|
|
|
|
wxThread::Sleep(300);
|
|
|
|
}
|
|
|
|
puts("Going to resume the thread");
|
|
|
|
|
|
|
|
thread->Resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait until the thread terminates
|
|
|
|
gs_cond.Wait();
|
|
|
|
|
|
|
|
puts("");
|
|
|
|
}
|
|
|
|
|
1999-11-30 21:55:00 +00:00
|
|
|
void TestThreadDelete()
|
|
|
|
{
|
|
|
|
// As above, using Sleep() is only for testing here - we must use some
|
|
|
|
// synchronisation object instead to ensure that the thread is still
|
|
|
|
// running when we delete it - deleting a detached thread which already
|
|
|
|
// terminated will lead to a crash!
|
|
|
|
|
|
|
|
puts("\n*** Testing thread delete function ***");
|
|
|
|
|
|
|
|
MyDetachedThread *thread1 = new MyDetachedThread(30, 'Y');
|
|
|
|
|
|
|
|
thread1->Run();
|
|
|
|
|
|
|
|
wxThread::Sleep(300);
|
|
|
|
|
|
|
|
thread1->Delete();
|
|
|
|
|
|
|
|
puts("\nDeleted a running thread.");
|
|
|
|
|
|
|
|
MyDetachedThread *thread2 = new MyDetachedThread(30, 'Z');
|
|
|
|
|
|
|
|
thread2->Run();
|
|
|
|
|
|
|
|
wxThread::Sleep(300);
|
|
|
|
|
|
|
|
thread2->Pause();
|
|
|
|
|
|
|
|
thread2->Delete();
|
|
|
|
|
|
|
|
puts("\nDeleted a sleeping thread.");
|
|
|
|
|
|
|
|
MyJoinableThread *thread3 = new MyJoinableThread(20);
|
|
|
|
thread3->Run();
|
|
|
|
|
|
|
|
thread3->Delete();
|
|
|
|
|
|
|
|
puts("\nDeleted a joinable thread.");
|
|
|
|
|
|
|
|
MyJoinableThread *thread4 = new MyJoinableThread(2);
|
|
|
|
thread4->Run();
|
|
|
|
|
|
|
|
wxThread::Sleep(300);
|
|
|
|
|
|
|
|
thread4->Delete();
|
|
|
|
|
|
|
|
puts("\nDeleted a joinable thread which already terminated.");
|
|
|
|
|
|
|
|
puts("");
|
|
|
|
}
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
#endif // TEST_THREADS
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// arrays
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef TEST_ARRAYS
|
|
|
|
|
|
|
|
void PrintArray(const char* name, const wxArrayString& array)
|
|
|
|
{
|
|
|
|
printf("Dump of the array '%s'\n", name);
|
|
|
|
|
|
|
|
size_t nCount = array.GetCount();
|
|
|
|
for ( size_t n = 0; n < nCount; n++ )
|
|
|
|
{
|
|
|
|
printf("\t%s[%u] = '%s'\n", name, n, array[n].c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TEST_ARRAYS
|
|
|
|
|
1999-11-29 23:05:23 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// strings
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef TEST_STRINGS
|
|
|
|
|
|
|
|
#include "wx/timer.h"
|
|
|
|
|
|
|
|
void TestString()
|
|
|
|
{
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
wxString a, b, c;
|
|
|
|
|
|
|
|
a.reserve (128);
|
|
|
|
b.reserve (128);
|
|
|
|
c.reserve (128);
|
|
|
|
|
|
|
|
for (int i = 0; i < 1000000; ++i)
|
|
|
|
{
|
|
|
|
a = "Hello";
|
|
|
|
b = " world";
|
|
|
|
c = "! How'ya doin'?";
|
|
|
|
a += b;
|
|
|
|
a += c;
|
|
|
|
c = "Hello world! What's up?";
|
|
|
|
if (c != a)
|
|
|
|
c = "Doh!";
|
|
|
|
}
|
|
|
|
|
|
|
|
printf ("TestString elapsed time: %ld\n", sw.Time());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPChar()
|
|
|
|
{
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
char a [128];
|
|
|
|
char b [128];
|
|
|
|
char c [128];
|
|
|
|
|
|
|
|
for (int i = 0; i < 1000000; ++i)
|
|
|
|
{
|
|
|
|
strcpy (a, "Hello");
|
|
|
|
strcpy (b, " world");
|
|
|
|
strcpy (c, "! How'ya doin'?");
|
|
|
|
strcat (a, b);
|
|
|
|
strcat (a, c);
|
|
|
|
strcpy (c, "Hello world! What's up?");
|
|
|
|
if (strcmp (c, a) == 0)
|
|
|
|
strcpy (c, "Doh!");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf ("TestPChar elapsed time: %ld\n", sw.Time());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TEST_STRINGS
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// entry point
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-07 18:12:57 +00:00
|
|
|
int main(int argc, char **argv)
|
1999-10-06 17:48:34 +00:00
|
|
|
{
|
|
|
|
if ( !wxInitialize() )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
|
|
|
|
}
|
|
|
|
|
1999-11-29 23:05:23 +00:00
|
|
|
#ifdef TEST_STRINGS
|
|
|
|
TestPChar();
|
|
|
|
TestString();
|
|
|
|
#endif // TEST_STRINGS
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
#ifdef TEST_ARRAYS
|
|
|
|
wxArrayString a1;
|
|
|
|
a1.Add("tiger");
|
|
|
|
a1.Add("cat");
|
|
|
|
a1.Add("lion");
|
|
|
|
a1.Add("dog");
|
|
|
|
a1.Add("human");
|
|
|
|
a1.Add("ape");
|
|
|
|
|
|
|
|
puts("*** Initially:");
|
|
|
|
|
|
|
|
PrintArray("a1", a1);
|
|
|
|
|
|
|
|
wxArrayString a2(a1);
|
|
|
|
PrintArray("a2", a2);
|
|
|
|
|
|
|
|
wxSortedArrayString a3(a1);
|
|
|
|
PrintArray("a3", a3);
|
|
|
|
|
|
|
|
puts("*** After deleting a string from a1");
|
|
|
|
a1.Remove(2);
|
|
|
|
|
|
|
|
PrintArray("a1", a1);
|
|
|
|
PrintArray("a2", a2);
|
|
|
|
PrintArray("a3", a3);
|
|
|
|
|
|
|
|
puts("*** After reassigning a1 to a2 and a3");
|
|
|
|
a3 = a2 = a1;
|
|
|
|
PrintArray("a2", a2);
|
|
|
|
PrintArray("a3", a3);
|
|
|
|
#endif // TEST_ARRAYS
|
|
|
|
|
1999-11-15 15:49:59 +00:00
|
|
|
#ifdef TEST_LOG
|
|
|
|
wxString s;
|
|
|
|
for ( size_t n = 0; n < 8000; n++ )
|
|
|
|
{
|
|
|
|
s << (char)('A' + (n % 26));
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf("A very very long message: '%s', the end!\n", s.c_str());
|
|
|
|
|
|
|
|
// this one shouldn't be truncated
|
|
|
|
printf(msg);
|
|
|
|
|
|
|
|
// but this one will because log functions use fixed size buffer
|
1999-11-27 22:57:06 +00:00
|
|
|
// (note that it doesn't need '\n' at the end neither - will be added
|
|
|
|
// by wxLog anyhow)
|
|
|
|
wxLogMessage("A very very long message 2: '%s', the end!", s.c_str());
|
1999-11-15 15:49:59 +00:00
|
|
|
#endif // TEST_LOG
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
#ifdef TEST_THREADS
|
1999-11-29 23:05:23 +00:00
|
|
|
if ( argc > 1 && argv[1][0] == 't' )
|
|
|
|
wxLog::AddTraceMask("thread");
|
1999-11-27 22:57:06 +00:00
|
|
|
|
1999-11-29 23:05:23 +00:00
|
|
|
if ( 0 )
|
1999-11-30 21:55:00 +00:00
|
|
|
TestDetachedThreads();
|
|
|
|
if ( 0 )
|
|
|
|
TestJoinableThreads();
|
|
|
|
if ( 0 )
|
|
|
|
TestThreadSuspend();
|
|
|
|
if ( 1 )
|
|
|
|
TestThreadDelete();
|
|
|
|
|
1999-10-22 09:24:15 +00:00
|
|
|
#endif // TEST_THREADS
|
1999-10-06 17:48:34 +00:00
|
|
|
|
1999-11-28 23:30:18 +00:00
|
|
|
#ifdef TEST_LONGLONG
|
|
|
|
if ( 0 )
|
|
|
|
TestSpeed();
|
|
|
|
if ( 1 )
|
|
|
|
TestDivision();
|
|
|
|
#endif // TEST_LONGLONG
|
|
|
|
|
|
|
|
#ifdef TEST_TIME
|
1999-11-30 21:55:00 +00:00
|
|
|
TestTimeStatic();
|
|
|
|
TestTimeSet();
|
1999-11-28 23:30:18 +00:00
|
|
|
#endif // TEST_TIME
|
|
|
|
|
1999-10-06 17:48:34 +00:00
|
|
|
wxUninitialize();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|