X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3c70014d966bbfa08d201ca24c825f2d88cc3975..cd15bcaf50ead53ccf9d50965312f0dc754affb4:/tests/archive/archivetest.h diff --git a/tests/archive/archivetest.h b/tests/archive/archivetest.h index eef3d45fe1..ea81436eac 100644 --- a/tests/archive/archivetest.h +++ b/tests/archive/archivetest.h @@ -7,6 +7,9 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// +#ifndef WX_ARCHIVETEST_INCLUDED +#define WX_ARCHIVETEST_INCLUDED 1 + #define WX_TEST_ARCHIVE_ITERATOR #include "wx/archive.h" @@ -60,8 +63,16 @@ private: class TestInputStream : public wxInputStream { public: + // various streams have implemented eof differently, so check the archive + // stream works with all the possibilities (bit flags that can be ORed) + enum EofTypes { + AtLast = 0x01, // eof before an attempt to read past the last byte + WithError = 0x02 // give an error instead of eof + }; + // ctor takes the data from the output stream, which is then empty - TestInputStream(TestOutputStream& out) : m_data(NULL) { SetData(out); } + TestInputStream(TestOutputStream& out, int eoftype) + : m_data(NULL), m_eoftype(eoftype) { SetData(out); } // this ctor 'dups' TestInputStream(const TestInputStream& in); ~TestInputStream() { delete [] m_data; } @@ -71,6 +82,9 @@ public: bool IsSeekable() const { return (m_options & PipeIn) == 0; } void SetData(TestOutputStream& out); + void Chop(size_t size) { m_size = size; } + char& operator [](size_t pos) { return m_data[pos]; } + private: wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); wxFileOffset OnSysTell() const; @@ -80,6 +94,7 @@ private: size_t m_pos; size_t m_size; char *m_data; + int m_eoftype; }; @@ -137,7 +152,6 @@ class ArchiveTestCase : public CppUnit::TestCase { public: ArchiveTestCase(std::string name, - int id, ClassFactoryT *factory, int options, const wxString& archiver = wxEmptyString, @@ -209,6 +223,22 @@ protected: }; +/////////////////////////////////////////////////////////////////////////////// +// Make ids + +class TestId +{ +public: + // make a new id and return it as a string + static std::string MakeId(); + // get the current id + static int GetId() { return m_seed; } +private: + // seed for generating the ids + static int m_seed; +}; + + /////////////////////////////////////////////////////////////////////////////// // Base class for the archive test suites @@ -218,12 +248,9 @@ public: ArchiveTestSuite(std::string name); protected: - int m_id; - virtual ArchiveTestSuite *makeSuite(); virtual CppUnit::Test *makeTest(std::string descr, - int id, int options, bool genericInterface, const wxString& archiver, @@ -247,3 +274,5 @@ private: void AddCmd(wxArrayString& cmdlist, const wxString& cmd); }; + +#endif