// what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
// test, define it to 1 to do all tests.
-#define TEST_ALL 0
+#define TEST_ALL 1
#if TEST_ALL
#define TEST_FILECONF
#define TEST_FILENAME
#define TEST_FILETIME
- // #define TEST_FTP --FIXME! (RN)
+ #define TEST_FTP
#define TEST_INFO_FUNCTIONS
#define TEST_LOCALE
#define TEST_LOG
// regular expressions
// ----------------------------------------------------------------------------
-#ifdef TEST_REGEX
+#if defined TEST_REGEX && TEST_INTERACTIVE
#include "wx/regex.h"
{
wxPuts(_T("*** Testing FTP connect ***"));
- // wxFTP cannot be a static variable as its ctor needs to access
- // wxWidgets internals after it has been initialized
- ftp = new wxFTP;
-
#ifdef FTP_ANONYMOUS
static const wxChar *hostname = _T("ftp.wxwidgets.org");
return true;
}
-// test (fixed?) wxFTP bug with wu-ftpd >= 2.6.0?
-static void TestFtpWuFtpd()
-{
- wxFTP ftp;
- static const wxChar *hostname = _T("ftp.eudora.com");
- if ( !ftp.Connect(hostname) )
- {
- wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname);
- }
- else
- {
- static const wxChar *filename = _T("eudora/pubs/draft-gellens-submit-09.txt");
- wxInputStream *in = ftp.GetInputStream(filename);
- if ( !in )
- {
- wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename);
- }
- else
- {
- size_t size = in->GetSize();
- wxPrintf(_T("Reading file %s (%u bytes)..."), filename, size);
-
- wxChar *data = new wxChar[size];
- if ( !in->Read(data, size) )
- {
- wxPuts(_T("ERROR: read error"));
- }
- else
- {
- wxPrintf(_T("Successfully retrieved the file.\n"));
- }
-
- delete [] data;
- delete in;
- }
- }
-}
-
static void TestFtpList()
{
wxPuts(_T("*** Testing wxFTP file listing ***\n"));
}
}
+#if TEST_INTERACTIVE
+
static void TestFtpInteractive()
{
wxPuts(_T("\n*** Interactive wxFTP test ***"));
wxPuts(_T("\n*** done ***"));
}
+#endif // TEST_INTERACTIVE
+
static void TestFtpUpload()
{
wxPuts(_T("*** Testing wxFTP uploading ***\n"));
{
}
- virtual void Walk(size_t skip = 1)
+ virtual void Walk(size_t skip = 1, size_t maxdepth = wxSTACKWALKER_MAX_DEPTH)
{
wxPuts(_T("Stack dump:"));
- wxStackWalker::Walk(skip);
+ wxStackWalker::Walk(skip, maxdepth);
}
protected:
{
wxFileInputStream fsIn(filename);
wxPrintf(_T("File stream size: %u\n"), fsIn.GetSize());
- while ( !fsIn.Eof() )
+ int c;
+ while ( (c=fsIn.GetC()) != wxEOF )
{
- wxPutchar(fsIn.GetC());
+ wxPutchar(c);
}
}
wxMemoryInputStream memInpStream(buf, len);
wxPrintf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
- while ( !memInpStream.Eof() )
+ int c;
+ while ( (c=memInpStream.GetC()) != wxEOF )
{
- wxPutchar(memInpStream.GetC());
+ wxPutchar(c);
}
wxPuts(_T("\n*** wxMemoryInputStream test done ***"));
wxPrintf(_T("Archive size: %u\n"), istr.GetSize());
wxPrintf(_T("Dumping the file '%s':\n"), filename.c_str());
- while ( !istr.Eof() )
+ int c;
+ while ( (c=istr.GetC()) != wxEOF )
{
- wxPutchar(istr.GetC());
+ wxPutchar(c);
fflush(stdout);
}
wxThread::Sleep(500);
}
-#include "wx/utils.h"
-
-class MyExecThread : public wxThread
-{
-public:
- MyExecThread(const wxString& command) : wxThread(wxTHREAD_JOINABLE),
- m_command(command)
- {
- Create();
- }
-
- virtual ExitCode Entry()
- {
- return (ExitCode)wxExecute(m_command, wxEXEC_SYNC);
- }
-
-private:
- wxString m_command;
-};
-
-static void TestThreadExec()
-{
- wxPuts(_T("*** Testing wxExecute interaction with threads ***\n"));
-
- MyExecThread thread(_T("true"));
- thread.Run();
-
- wxPrintf(_T("Main program exit code: %ld.\n"),
- wxExecute(_T("false"), wxEXEC_SYNC));
-
- wxPrintf(_T("Thread exit code: %ld.\n"), (long)thread.Wait());
-}
-
// semaphore tests
#include "wx/datetime.h"
#ifdef TEST_FTP
wxLog::AddTraceMask(FTP_TRACE_MASK);
+
+ // wxFTP cannot be a static variable as its ctor needs to access
+ // wxWidgets internals after it has been initialized
+ ftp = new wxFTP;
+
if ( TestFtpConnect() )
{
#if TEST_ALL
#endif // TEST_ALL
#if TEST_INTERACTIVE
- TestFtpInteractive();
+ //TestFtpInteractive();
#endif
}
//else: connecting to the FTP server failed
- #if 0
- TestFtpWuFtpd();
- #endif
+ delete ftp;
#endif // TEST_FTP
#ifdef TEST_MIME
TestThreadSuspend();
TestThreadDelete();
TestThreadConditions();
- TestThreadExec();
TestSemaphore();
#endif
#endif // TEST_THREADS