#undef TEST_ALL
static const bool TEST_ALL = TRUE;
#else
- #define TEST_FILENAME
+ #define TEST_STREAMS
static const bool TEST_ALL = FALSE;
#endif
puts("*** Testing wxDir::GetFirst/GetNext ***");
wxString cwd = wxGetCwd();
- if ( wxDir::Exists(cwd) )
+ if ( !wxDir::Exists(cwd) )
{
printf("ERROR: current directory '%s' doesn't exist?\n", cwd.c_str());
return;
}
- wxDir dir(cwd);
+ wxDir dir("s:/tmp/foo");
if ( !dir.IsOpened() )
{
printf("ERROR: failed to open current directory '%s'.\n", cwd.c_str());
_T("readme.txt"),
_T("document.pdf"),
_T("image.gif"),
+ _T("picture.jpeg"),
};
for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
static void TestMemoryStream()
{
- puts("*** Testing wxMemoryInputStream ***");
+ wxPuts(_T("*** Testing wxMemoryOutputStream ***"));
+
+ wxMemoryOutputStream memOutStream;
+ wxPrintf(_T("Initially out stream offset: %lu\n"),
+ (unsigned long)memOutStream.TellO());
+
+ for ( const wxChar *p = _T("Hello, stream!"); *p; p++ )
+ {
+ memOutStream.PutC(*p);
+ }
+
+ wxPrintf(_T("Final out stream offset: %lu\n"),
+ (unsigned long)memOutStream.TellO());
+
+ wxPuts(_T("*** Testing wxMemoryInputStream ***"));
wxChar buf[1024];
- wxStrncpy(buf, _T("Hello, stream!"), WXSIZEOF(buf));
+ size_t len = memOutStream.CopyTo(buf, WXSIZEOF(buf));
- wxMemoryInputStream memInpStream(buf, wxStrlen(buf));
- printf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
+ wxMemoryInputStream memInpStream(buf, len);
+ wxPrintf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
while ( !memInpStream.Eof() )
{
putchar(memInpStream.GetC());
virtual ExitCode Entry()
{
- wxPrintf(_T("%s: Thread %d starting to wait for semaphore...\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) starting to wait for semaphore...\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());
m_sem->Wait();
- wxPrintf(_T("%s: Thread %d acquired the semaphore.\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) acquired the semaphore.\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());
Sleep(1000);
- wxPrintf(_T("%s: Thread %d releasing the semaphore.\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) releasing the semaphore.\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());
m_sem->Post();
#endif // TEST_ARRAYS
#ifdef TEST_DIR
- TestDirExists();
if ( TEST_ALL )
{
- TestDirEnum();
+ TestDirExists();
TestDirTraverse();
}
+ TestDirEnum();
#endif // TEST_DIR
#ifdef TEST_DLLLOADER
{
TestMimeEnum();
TestMimeOverride();
- TestMimeFilename();
+ TestMimeAssociate();
}
-
- TestMimeAssociate();
+ TestMimeFilename();
#endif // TEST_MIME
#ifdef TEST_INFO_FUNCTIONS
#endif // TEST_SOCKETS
#ifdef TEST_STREAMS
- TestFileStream();
- TestMemoryStream();
+ if ( TEST_ALL )
+ {
+ TestFileStream();
+ }
+ TestMemoryStream();
#endif // TEST_STREAMS
#ifdef TEST_THREADS