-template <class Classes>
-class ArchiveTestCase : public CppUnit::TestCase
-{
-public:
- ArchiveTestCase(const wxString& name,
- int id,
- typename Classes::ClassFactoryT *factory,
- int options,
- const wxString& archiver = wxEmptyString,
- const wxString& unarchiver = wxEmptyString);
-
- ~ArchiveTestCase();
-
-protected:
- // the classes to test
- typedef typename Classes::EntryT EntryT;
- typedef typename Classes::InputStreamT InputStreamT;
- typedef typename Classes::OutputStreamT OutputStreamT;
- typedef typename Classes::ClassFactoryT ClassFactoryT;
- typedef typename Classes::NotifierT NotifierT;
- typedef typename Classes::IterT IterT;
- typedef typename Classes::PairIterT PairIterT;
-
- // the entry point for the test
- void runTest();
-
- // create the test data
- void CreateTestData();
- TestEntry& Add(const char *name, const char *data, int len = -1);
- TestEntry& Add(const char *name, int len = 0, int value = EOF);
-
- // 'archive up' the test data
- void CreateArchive(wxOutputStream& out);
- void CreateArchive(wxOutputStream& out, const wxString& archiver);
-
- // perform various modifications on the archive
- void ModifyArchive(wxInputStream& in, wxOutputStream& out);
-
- // extract the archive and verify its contents
- void ExtractArchive(wxInputStream& in);
- void ExtractArchive(wxInputStream& in, const wxString& unarchiver);
- void VerifyDir(wxString& path, size_t rootlen = 0);
-
- // tests for the iterators
- void TestIterator(wxInputStream& in);
- void TestPairIterator(wxInputStream& in);
- void TestSmartIterator(wxInputStream& in);
- void TestSmartPairIterator(wxInputStream& in);
-
- // try reading two entries at the same time
- void ReadSimultaneous(TestInputStream& in);
-
- // overridables
- virtual void OnCreateArchive(OutputStreamT& WXUNUSED(arc)) { }
- virtual void OnSetNotifier(EntryT& entry);
-
- virtual void OnArchiveExtracted(InputStreamT& WXUNUSED(arc),
- int WXUNUSED(expectedTotal)) { }
-
- virtual void OnCreateEntry( OutputStreamT& WXUNUSED(arc),
- TestEntry& WXUNUSED(testEntry),
- EntryT *entry = NULL) { (void)entry; }
-
- virtual void OnEntryExtracted( EntryT& WXUNUSED(entry),
- const TestEntry& WXUNUSED(testEntry),
- InputStreamT *arc = NULL) { (void)arc; }
-
- typedef std::map<wxString, TestEntry*> TestEntries;
- TestEntries m_testEntries; // test data
- std::auto_ptr<ClassFactoryT> m_factory; // factory to make classes
- int m_options; // test options
- wxDateTime m_timeStamp; // timestamp to give test entries
- int m_id; // select between the possibilites
- wxString m_archiver; // external archiver
- wxString m_unarchiver; // external unarchiver
-};
-
-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())),