]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/archive/archivetest.cpp
rebaked after adding src/tiff/tif_color.c
[wxWidgets.git] / tests / archive / archivetest.cpp
index e836c3a16eb433e4e7d1c3dc539b63c835e594d4..636ef41940c3d821e39f78d1e2e0abc622be73a0 100644 (file)
@@ -7,7 +7,7 @@
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "wx/wxprec.h"
+#include "testprec.h"
 
 #ifdef __BORLANDC__
 #   pragma hdrstop
@@ -25,7 +25,6 @@
 #include "wx/mstream.h"
 #include "wx/wfstream.h"
 #include "wx/dir.h"
-#include "wx/cppunit.h"
 #include <string>
 #include <list>
 #include <sys/stat.h>
@@ -104,7 +103,7 @@ class TestEntry
 {
 public:
     TestEntry(const wxDateTime& dt, int len, const char *data);
-    ~TestEntry() { delete [] m_data; }
+    ~TestEntry() { delete [] (char*) m_data; }
 
     wxDateTime GetDateTime() const  { return m_dt; }
     wxFileOffset GetLength() const  { return m_len; }
@@ -150,7 +149,7 @@ public:
     ~TestOutputStream() { delete [] m_data; }
 
     int GetOptions() const { return m_options; }
-    size_t GetSize() const { return m_size; }
+    wxFileOffset GetLength() const { return m_size; }
 
     // gives away the data, this stream is then empty, and can be reused
     void GetData(const char*& data, size_t& size);
@@ -209,7 +208,7 @@ wxFileOffset TestOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
 
 wxFileOffset TestOutputStream::OnSysTell() const
 {
-    return (m_options & PipeOut) == 0 ? m_pos : wxInvalidOffset;
+    return (m_options & PipeOut) == 0 ? (wxFileOffset)m_pos : wxInvalidOffset;
 }
 
 size_t TestOutputStream::OnSysWrite(const void *buffer, size_t size)
@@ -279,10 +278,10 @@ public:
     TestInputStream(TestOutputStream& out) : m_data(NULL) { SetData(out); }
     // this ctor 'dups'
     TestInputStream(const TestInputStream& in);
-    ~TestInputStream() { delete [] m_data; }
+    ~TestInputStream() { delete [] (char*) m_data; }
 
     void Rewind();
-    size_t GetSize() const { return m_size; }
+    wxFileOffset GetLength() const { return m_size; }
     void SetData(TestOutputStream& out);
 
 private:
@@ -323,7 +322,7 @@ void TestInputStream::Rewind()
 
 void TestInputStream::SetData(TestOutputStream& out)
 {
-    delete [] m_data;
+    delete [] (char*) m_data;
     m_options = out.GetOptions();
     out.GetData(m_data, m_size);
     Rewind();
@@ -348,7 +347,7 @@ wxFileOffset TestInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
 
 wxFileOffset TestInputStream::OnSysTell() const
 {
-    return (m_options & PipeIn) == 0 ? m_pos : wxInvalidOffset;
+    return (m_options & PipeIn) == 0 ? (wxFileOffset)m_pos : wxInvalidOffset;
 }
 
 size_t TestInputStream::OnSysRead(void *buffer, size_t size)
@@ -602,21 +601,21 @@ protected:
 
 template <class Classes>
 ArchiveTestCase<Classes>::ArchiveTestCase(const wxString& name,
-                                          int id,
-                                          ClassFactoryT *factory,
-                                          int options,
-                                          const wxString& archiver,
-                                          const wxString& unarchiver)
-  : CppUnit::TestCase(std::string(name.mb_str())),
-    m_factory(factory),
-    m_options(options),
-    m_timeStamp(1, wxDateTime::Mar, 2005, 12, 0),
-    m_id(id),
-    m_archiver(archiver),
-    m_unarchiver(unarchiver)
+                int id,
+                typename Classes::ClassFactoryT *factory,
+                int options,
+                const wxString& archiver,
+                const wxString& unarchiver)
+                : CppUnit::TestCase(std::string(name.mb_str())),
+                    m_factory(factory),
+                    m_options(options),
+                    m_timeStamp(1, wxDateTime::Mar, 2005, 12, 0),
+                    m_id(id),
+                    m_archiver(archiver),
+                    m_unarchiver(unarchiver)
 {
 }
-
+    
 template <class Classes>
 ArchiveTestCase<Classes>::~ArchiveTestCase()
 {
@@ -638,7 +637,7 @@ void ArchiveTestCase<Classes>::runTest()
         CreateArchive(out, m_archiver);
 
     // check archive could be created
-    CPPUNIT_ASSERT(out.GetSize() > 0);
+    CPPUNIT_ASSERT(out.GetLength() > 0);
 
     TestInputStream in(out);
 
@@ -975,8 +974,8 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
             testEntry.GetLength() == entry->GetSize() ||
             ((m_options & PipeIn) != 0 && entry->GetSize() == wxInvalidOffset));
         CPPUNIT_ASSERT_MESSAGE(
-            "arc->GetSize() == entry->GetSize()" + error_context,
-            arc->GetSize() == (size_t)entry->GetSize());
+            "arc->GetLength() == entry->GetSize()" + error_context,
+            arc->GetLength() == entry->GetSize());
 
         if (name.Last() != _T('/'))
         {
@@ -998,8 +997,8 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
         CPPUNIT_ASSERT_MESSAGE("entry size check" + error_context,
             testEntry.GetLength() == entry->GetSize());
         CPPUNIT_ASSERT_MESSAGE(
-            "arc->GetSize() == entry->GetSize()" + error_context,
-            arc->GetSize() == (size_t)entry->GetSize());
+            "arc->GetLength() == entry->GetSize()" + error_context,
+            arc->GetLength() == entry->GetSize());
 
         if ((m_options & PipeIn) == 0) {
             OnEntryExtracted(*entry, testEntry, arc.get());
@@ -1102,7 +1101,6 @@ void ArchiveTestCase<Classes>::VerifyDir(wxString& path, size_t rootlen /*=0*/)
                 it != m_testEntries.end());
 
             const TestEntry& testEntry = *it->second;
-            size_t size = 0;
 
 #ifndef __WXMSW__
             CPPUNIT_ASSERT_MESSAGE("timestamp check" + error_context,
@@ -1114,7 +1112,7 @@ void ArchiveTestCase<Classes>::VerifyDir(wxString& path, size_t rootlen /*=0*/)
                 CPPUNIT_ASSERT_MESSAGE(
                     "entry not found in archive" + error_entry, in.Ok());
 
-                size = in.GetSize();
+                size_t size = in.GetLength();
                 wxCharBuffer buf(size);
                 CPPUNIT_ASSERT_MESSAGE("Read" + error_context,
                     in.Read(buf.data(), size).LastRead() == size);