removed zlib tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -89,8 +89,6 @@
|
||||
// #define TEST_VOLUME --FIXME! (RN)
|
||||
#define TEST_WCHAR
|
||||
#define TEST_ZIP
|
||||
#define TEST_ZLIB
|
||||
#define TEST_GZIP
|
||||
|
||||
#else // #if TEST_ALL
|
||||
|
||||
@@ -4059,190 +4057,6 @@ static void TestZipFileSystem()
|
||||
|
||||
#endif // TEST_ZIP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ZLIB stream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_ZLIB
|
||||
|
||||
#include "wx/zstream.h"
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
static const wxString FILENAME_GZ = _T("test.gz");
|
||||
static const wxChar *TEST_DATA = _T("hello and hello and hello and hello and hello");
|
||||
|
||||
static void TestZlibStreamWrite()
|
||||
{
|
||||
wxPuts(_T("*** Testing Zlib stream reading ***\n"));
|
||||
|
||||
wxFileOutputStream fileOutStream(FILENAME_GZ);
|
||||
wxZlibOutputStream ostr(fileOutStream);
|
||||
wxPrintf(_T("Compressing the test string... "));
|
||||
ostr.Write(TEST_DATA, wxStrlen(TEST_DATA) + 1);
|
||||
if ( !ostr )
|
||||
{
|
||||
wxPuts(_T("(ERROR: failed)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPuts(_T("(ok)"));
|
||||
}
|
||||
|
||||
wxPuts(_T("\n----- done ------"));
|
||||
}
|
||||
|
||||
static void TestZlibStreamRead()
|
||||
{
|
||||
wxPuts(_T("*** Testing Zlib stream reading ***\n"));
|
||||
|
||||
wxFileInputStream fileInStream(FILENAME_GZ);
|
||||
wxZlibInputStream istr(fileInStream);
|
||||
wxPrintf(_T("Archive size: %u\n"), istr.GetSize());
|
||||
|
||||
wxPuts(_T("Dumping the file:"));
|
||||
while ( !istr.Eof() )
|
||||
{
|
||||
wxPutchar(istr.GetC());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
wxPuts(_T("\n----- done ------"));
|
||||
}
|
||||
|
||||
#endif // TEST_ZLIB
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Gzip streams
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_GZIP
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/gzstream.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/txtstrm.h"
|
||||
|
||||
// Reads two input streams and verifies that they are the same (and non-emtpy)
|
||||
//
|
||||
void GzipVerify(wxInputStream &in1, wxInputStream &in2)
|
||||
{
|
||||
if (!in1 || !in2) {
|
||||
wxPuts(_T(" Can't verify"));
|
||||
return;
|
||||
}
|
||||
|
||||
const int BUFSIZE = 8192;
|
||||
wxCharBuffer buf1(BUFSIZE);
|
||||
wxCharBuffer buf2(BUFSIZE);
|
||||
bool none = true;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int n1 = in1.Read(buf1.data(), BUFSIZE).LastRead();
|
||||
int n2 = in2.Read(buf2.data(), BUFSIZE).LastRead();
|
||||
|
||||
if (n1 != n2 || (n1 && memcmp(buf1, buf2, n1) != 0) || (!n1 && none)) {
|
||||
wxPuts(_T(" Failure"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!n1) {
|
||||
wxPuts(_T(" Success"));
|
||||
break;
|
||||
}
|
||||
|
||||
none = false;
|
||||
}
|
||||
|
||||
while (in1.IsOk())
|
||||
in1.Read(buf1.data(), BUFSIZE);
|
||||
while (in2.IsOk())
|
||||
in2.Read(buf2.data(), BUFSIZE);
|
||||
}
|
||||
|
||||
// Write a gzip file and read it back.
|
||||
//
|
||||
void TestGzip()
|
||||
{
|
||||
wxPuts(_T("*** Testing gzip streams ***\n"));
|
||||
|
||||
const wxString testname = _T("gziptest");
|
||||
const wxString gzipname = testname + _T(".gz");
|
||||
|
||||
// write some random test data to a testfile
|
||||
wxPuts(_T("Writing random test data to ") + testname + _T("..."));
|
||||
{
|
||||
wxFFileOutputStream outstream(testname);
|
||||
wxTextOutputStream textout(outstream);
|
||||
|
||||
for (int i = 0; i < 1000 && outstream.Ok(); i++)
|
||||
textout << rand() << rand() << rand() << rand() << endl;
|
||||
|
||||
wxPuts(_T(" Done"));
|
||||
}
|
||||
|
||||
wxFileName fn(testname);
|
||||
wxDateTime dt = fn.GetModificationTime();
|
||||
wxFFileInputStream instream(testname);
|
||||
|
||||
// try writing a gzip file
|
||||
wxPuts(_T("Writing ") + gzipname + _T(" using wxGzipOutputStream..."));
|
||||
{
|
||||
wxFFileOutputStream outstream(gzipname);
|
||||
wxGzipOutputStream gzip(outstream, testname, dt);
|
||||
|
||||
if (!gzip.Write(instream))
|
||||
wxPuts(_T(" Failure"));
|
||||
else
|
||||
wxPuts(_T(" Success"));
|
||||
}
|
||||
|
||||
// try reading the gzip file
|
||||
wxPuts(_T("Reading ") + gzipname + _T(" using wxGzipInputStream..."));
|
||||
{
|
||||
instream.SeekI(0);
|
||||
wxFFileInputStream instream2(gzipname);
|
||||
wxGzipInputStream gzip(instream2);
|
||||
GzipVerify(instream, gzip);
|
||||
|
||||
if (gzip.GetName() != fn.GetFullName())
|
||||
wxPuts(gzipname + _T(" contains incorrect filename: ")
|
||||
+ gzip.GetName());
|
||||
if (dt.IsValid() && gzip.GetDateTime() != dt)
|
||||
wxPuts(gzipname + _T(" contains incorrect timestamp: ")
|
||||
+ gzip.GetDateTime().Format());
|
||||
}
|
||||
|
||||
#ifdef __UNIX__
|
||||
// then verify it using gzip program if it is in the path
|
||||
wxPuts(_T("Reading ") + gzipname + _T(" using gzip program..."));
|
||||
wxFFile file(popen((_T("gzip -d -c ") + gzipname).mb_str(), "r"));
|
||||
if (file.fp()) {
|
||||
wxFFileInputStream instream2(file);
|
||||
instream.SeekI(0);
|
||||
GzipVerify(instream, instream2);
|
||||
pclose(file.fp());
|
||||
file.Detach();
|
||||
}
|
||||
|
||||
// try reading a gzip created by gzip program
|
||||
wxPuts(_T("Reading output of gzip program using wxGzipInputStream..."));
|
||||
file.Attach(popen((_T("gzip -c ") + testname).mb_str(), "r"));
|
||||
if (file.fp()) {
|
||||
wxFFileInputStream instream2(file);
|
||||
wxGzipInputStream gzip(instream2);
|
||||
instream.SeekI(0);
|
||||
GzipVerify(instream, gzip);
|
||||
pclose(file.fp());
|
||||
file.Detach();
|
||||
}
|
||||
#endif
|
||||
|
||||
wxPuts(_T("\n--- Done gzip streams ---"));
|
||||
}
|
||||
|
||||
#endif // TEST_GZIP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// date time
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -6108,15 +5922,6 @@ int main(int argc, char **argv)
|
||||
TestZipFileSystem();
|
||||
#endif // TEST_ZIP
|
||||
|
||||
#ifdef TEST_ZLIB
|
||||
TestZlibStreamWrite();
|
||||
TestZlibStreamRead();
|
||||
#endif // TEST_ZLIB
|
||||
|
||||
#ifdef TEST_GZIP
|
||||
TestGzip();
|
||||
#endif
|
||||
|
||||
wxUnusedVar(argc);
|
||||
wxUnusedVar(argv);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user