Lots and lots and lots of MSVC fixes for archive stuff, some stuff from patch 1071373
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
36b79d445d
commit
95662a8379
@ -284,14 +284,12 @@ public:
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator ==(const wxArchiveIterator& i,
|
bool operator ==(const wxArchiveIterator& j) {
|
||||||
const wxArchiveIterator& j) {
|
return (*this).m_rep == j.m_rep;
|
||||||
return i.m_rep == j.m_rep;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator !=(const wxArchiveIterator& i,
|
bool operator !=(const wxArchiveIterator& j) {
|
||||||
const wxArchiveIterator& j) {
|
return !(*this == j);
|
||||||
return !(i == j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -21,14 +21,25 @@
|
|||||||
|
|
||||||
#define WX_TEST_ARCHIVE_ITERATOR
|
#define WX_TEST_ARCHIVE_ITERATOR
|
||||||
|
|
||||||
|
// This sample uses some advanced typedef syntax that messes
|
||||||
|
// up MSVC 6 - turn off its warning about it
|
||||||
|
#if defined _MSC_VER
|
||||||
|
#pragma warning (disable:4284)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/zipstrm.h"
|
#include "wx/zipstrm.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/dir.h"
|
#include "wx/dir.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::auto_ptr;
|
||||||
|
|
||||||
|
|
||||||
// Check whether member templates can be used
|
// Check whether member templates can be used
|
||||||
//
|
//
|
||||||
#if defined __GNUC__ && \
|
#if defined __GNUC__ && \
|
||||||
@ -200,7 +211,7 @@ wxFileOffset TestOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
}
|
}
|
||||||
if (pos < 0 || pos > SEEK_LIMIT)
|
if (pos < 0 || pos > SEEK_LIMIT)
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
m_pos = pos;
|
m_pos = (size_t)pos;
|
||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
@ -339,7 +350,7 @@ wxFileOffset TestInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
}
|
}
|
||||||
if (pos < 0 || pos > TestOutputStream::SEEK_LIMIT)
|
if (pos < 0 || pos > TestOutputStream::SEEK_LIMIT)
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
m_pos = pos;
|
m_pos = (size_t)pos;
|
||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
@ -526,9 +537,9 @@ template <class Classes>
|
|||||||
class ArchiveTestCase : public CppUnit::TestCase
|
class ArchiveTestCase : public CppUnit::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArchiveTestCase(const wxString& name,
|
ArchiveTestCase(string name,
|
||||||
int id,
|
int id,
|
||||||
typename Classes::ClassFactoryT *factory,
|
wxArchiveClassFactory *factory,
|
||||||
int options,
|
int options,
|
||||||
const wxString& archiver = wxEmptyString,
|
const wxString& archiver = wxEmptyString,
|
||||||
const wxString& unarchiver = wxEmptyString);
|
const wxString& unarchiver = wxEmptyString);
|
||||||
@ -591,7 +602,7 @@ protected:
|
|||||||
|
|
||||||
typedef std::map<wxString, TestEntry*> TestEntries;
|
typedef std::map<wxString, TestEntry*> TestEntries;
|
||||||
TestEntries m_testEntries; // test data
|
TestEntries m_testEntries; // test data
|
||||||
std::auto_ptr<ClassFactoryT> m_factory; // factory to make classes
|
auto_ptr<ClassFactoryT> m_factory; // factory to make classes
|
||||||
int m_options; // test options
|
int m_options; // test options
|
||||||
wxDateTime m_timeStamp; // timestamp to give test entries
|
wxDateTime m_timeStamp; // timestamp to give test entries
|
||||||
int m_id; // select between the possibilites
|
int m_id; // select between the possibilites
|
||||||
@ -599,21 +610,32 @@ protected:
|
|||||||
wxString m_unarchiver; // external unarchiver
|
wxString m_unarchiver; // external unarchiver
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
// The only way I could get this to compile on VC++ 5.0 was to pass 'factory'
|
||||||
|
// as a wxArchiveFactory* then cast it, even then only with some ifdefing.
|
||||||
|
//
|
||||||
template <class Classes>
|
template <class Classes>
|
||||||
ArchiveTestCase<Classes>::ArchiveTestCase(const wxString& name,
|
ArchiveTestCase<Classes>::ArchiveTestCase(
|
||||||
|
string name,
|
||||||
int id,
|
int id,
|
||||||
typename Classes::ClassFactoryT *factory,
|
wxArchiveClassFactory *factory,
|
||||||
int options,
|
int options,
|
||||||
const wxString& archiver,
|
const wxString& archiver,
|
||||||
const wxString& unarchiver)
|
const wxString& unarchiver)
|
||||||
: CppUnit::TestCase(std::string(name.mb_str())),
|
:
|
||||||
m_factory(factory),
|
CppUnit::TestCase(name),
|
||||||
|
#if defined _MSC_VER && _MSC_VER < 1300
|
||||||
|
m_factory(dynamic_cast<Classes::ClassFactoryT*>(factory)),
|
||||||
|
#else
|
||||||
|
m_factory(dynamic_cast<typename Classes::ClassFactoryT*>(factory)),
|
||||||
|
#endif
|
||||||
m_options(options),
|
m_options(options),
|
||||||
m_timeStamp(1, wxDateTime::Mar, 2005, 12, 0),
|
m_timeStamp(1, wxDateTime::Mar, 2005, 12, 0),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_archiver(archiver),
|
m_archiver(archiver),
|
||||||
m_unarchiver(unarchiver)
|
m_unarchiver(unarchiver)
|
||||||
{
|
{
|
||||||
|
wxASSERT(m_factory.get() != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Classes>
|
template <class Classes>
|
||||||
@ -721,7 +743,7 @@ TestEntry& ArchiveTestCase<Classes>::Add(const char *name,
|
|||||||
template <class Classes>
|
template <class Classes>
|
||||||
void ArchiveTestCase<Classes>::CreateArchive(wxOutputStream& out)
|
void ArchiveTestCase<Classes>::CreateArchive(wxOutputStream& out)
|
||||||
{
|
{
|
||||||
std::auto_ptr<OutputStreamT> arc(m_factory->NewStream(out));
|
auto_ptr<OutputStreamT> arc(m_factory->NewStream(out));
|
||||||
TestEntries::iterator it;
|
TestEntries::iterator it;
|
||||||
|
|
||||||
OnCreateArchive(*arc);
|
OnCreateArchive(*arc);
|
||||||
@ -744,12 +766,12 @@ void ArchiveTestCase<Classes>::CreateArchive(wxOutputStream& out)
|
|||||||
|
|
||||||
// provide some context for the error message so that we know which
|
// provide some context for the error message so that we know which
|
||||||
// iteration of the loop we were on
|
// iteration of the loop we were on
|
||||||
std::string error_entry((_T(" '") + name + _T("'")).mb_str());
|
string error_entry((_T(" '") + name + _T("'")).mb_str());
|
||||||
std::string error_context(" failed for entry" + error_entry);
|
string error_context(" failed for entry" + error_entry);
|
||||||
|
|
||||||
if ((choices & 2) || testEntry.IsText()) {
|
if ((choices & 2) || testEntry.IsText()) {
|
||||||
// try PutNextEntry(EntryT *pEntry)
|
// try PutNextEntry(EntryT *pEntry)
|
||||||
std::auto_ptr<EntryT> entry(m_factory->NewEntry());
|
auto_ptr<EntryT> entry(m_factory->NewEntry());
|
||||||
entry->SetName(name, wxPATH_UNIX);
|
entry->SetName(name, wxPATH_UNIX);
|
||||||
if (setIsDir)
|
if (setIsDir)
|
||||||
entry->SetIsDir();
|
entry->SetIsDir();
|
||||||
@ -860,9 +882,9 @@ template <class Classes>
|
|||||||
void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
||||||
wxOutputStream& out)
|
wxOutputStream& out)
|
||||||
{
|
{
|
||||||
std::auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
|
||||||
std::auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
|
auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
|
||||||
std::auto_ptr<EntryT> entry;
|
;
|
||||||
|
|
||||||
const wxString deleteName = _T("bin/bin1000");
|
const wxString deleteName = _T("bin/bin1000");
|
||||||
const wxString renameFrom = _T("zero/zero1024");
|
const wxString renameFrom = _T("zero/zero1024");
|
||||||
@ -872,14 +894,19 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
|||||||
|
|
||||||
arcOut->CopyArchiveMetaData(*arcIn);
|
arcOut->CopyArchiveMetaData(*arcIn);
|
||||||
|
|
||||||
while (entry.reset(arcIn->GetNextEntry()), entry.get() != NULL) {
|
auto_ptr<EntryT>* pEntry;
|
||||||
OnSetNotifier(*entry);
|
|
||||||
wxString name = entry->GetName(wxPATH_UNIX);
|
for (pEntry = new auto_ptr<EntryT>(arcIn->GetNextEntry()) ;
|
||||||
|
pEntry->get() != NULL ;
|
||||||
|
delete pEntry, pEntry = new auto_ptr<EntryT>(arcIn->GetNextEntry()))
|
||||||
|
{
|
||||||
|
OnSetNotifier(**pEntry);
|
||||||
|
wxString name = (*pEntry)->GetName(wxPATH_UNIX);
|
||||||
|
|
||||||
// provide some context for the error message so that we know which
|
// provide some context for the error message so that we know which
|
||||||
// iteration of the loop we were on
|
// iteration of the loop we were on
|
||||||
std::string error_entry((_T(" '") + name + _T("'")).mb_str());
|
string error_entry((_T(" '") + name + _T("'")).mb_str());
|
||||||
std::string error_context(" failed for entry" + error_entry);
|
string error_context(" failed for entry" + error_entry);
|
||||||
|
|
||||||
if (name == deleteName) {
|
if (name == deleteName) {
|
||||||
TestEntries::iterator it = m_testEntries.find(name);
|
TestEntries::iterator it = m_testEntries.find(name);
|
||||||
@ -892,7 +919,7 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (name == renameFrom) {
|
if (name == renameFrom) {
|
||||||
entry->SetName(renameTo);
|
(*pEntry)->SetName(renameTo);
|
||||||
TestEntries::iterator it = m_testEntries.find(renameFrom);
|
TestEntries::iterator it = m_testEntries.find(renameFrom);
|
||||||
CPPUNIT_ASSERT_MESSAGE(
|
CPPUNIT_ASSERT_MESSAGE(
|
||||||
"rename failed (already renamed?) for" + error_entry,
|
"rename failed (already renamed?) for" + error_entry,
|
||||||
@ -903,10 +930,12 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CPPUNIT_ASSERT_MESSAGE("CopyEntry" + error_context,
|
CPPUNIT_ASSERT_MESSAGE("CopyEntry" + error_context,
|
||||||
arcOut->CopyEntry(entry.release(), *arcIn));
|
arcOut->CopyEntry(pEntry->release(), *arcIn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete pEntry;
|
||||||
|
|
||||||
// check that the deletion and rename were done
|
// check that the deletion and rename were done
|
||||||
CPPUNIT_ASSERT(m_testEntries.count(deleteName) == 0);
|
CPPUNIT_ASSERT(m_testEntries.count(deleteName) == 0);
|
||||||
CPPUNIT_ASSERT(m_testEntries.count(renameFrom) == 0);
|
CPPUNIT_ASSERT(m_testEntries.count(renameFrom) == 0);
|
||||||
@ -917,13 +946,13 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
|
|||||||
|
|
||||||
// try adding a new entry
|
// try adding a new entry
|
||||||
TestEntry& testEntry = Add(newName.mb_str(), newData);
|
TestEntry& testEntry = Add(newName.mb_str(), newData);
|
||||||
entry.reset(m_factory->NewEntry());
|
auto_ptr<EntryT> newentry(m_factory->NewEntry());
|
||||||
entry->SetName(newName);
|
newentry->SetName(newName);
|
||||||
entry->SetDateTime(testEntry.GetDateTime());
|
newentry->SetDateTime(testEntry.GetDateTime());
|
||||||
entry->SetSize(testEntry.GetLength());
|
newentry->SetSize(testEntry.GetLength());
|
||||||
OnCreateEntry(*arcOut, testEntry, entry.get());
|
OnCreateEntry(*arcOut, testEntry, newentry.get());
|
||||||
OnSetNotifier(*entry);
|
OnSetNotifier(*newentry);
|
||||||
CPPUNIT_ASSERT(arcOut->PutNextEntry(entry.release()));
|
CPPUNIT_ASSERT(arcOut->PutNextEntry(newentry.release()));
|
||||||
CPPUNIT_ASSERT(arcOut->Write(newData, strlen(newData)).IsOk());
|
CPPUNIT_ASSERT(arcOut->Write(newData, strlen(newData)).IsOk());
|
||||||
|
|
||||||
// should work with or without explicit Close
|
// should work with or without explicit Close
|
||||||
@ -940,7 +969,7 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
|
|||||||
typedef std::list<EntryPtr> Entries;
|
typedef std::list<EntryPtr> Entries;
|
||||||
typedef typename Entries::iterator EntryIter;
|
typedef typename Entries::iterator EntryIter;
|
||||||
|
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
int expectedTotal = m_testEntries.size();
|
int expectedTotal = m_testEntries.size();
|
||||||
EntryPtr entry;
|
EntryPtr entry;
|
||||||
Entries entries;
|
Entries entries;
|
||||||
@ -953,8 +982,8 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
|
|||||||
|
|
||||||
// provide some context for the error message so that we know which
|
// provide some context for the error message so that we know which
|
||||||
// iteration of the loop we were on
|
// iteration of the loop we were on
|
||||||
std::string error_entry((_T(" '") + name + _T("'")).mb_str());
|
string error_entry((_T(" '") + name + _T("'")).mb_str());
|
||||||
std::string error_context(" failed for entry" + error_entry);
|
string error_context(" failed for entry" + error_entry);
|
||||||
|
|
||||||
TestEntries::iterator it = m_testEntries.find(name);
|
TestEntries::iterator it = m_testEntries.find(name);
|
||||||
CPPUNIT_ASSERT_MESSAGE(
|
CPPUNIT_ASSERT_MESSAGE(
|
||||||
@ -1091,8 +1120,8 @@ void ArchiveTestCase<Classes>::VerifyDir(wxString& path, size_t rootlen /*=0*/)
|
|||||||
|
|
||||||
// provide some context for the error message so that we know which
|
// provide some context for the error message so that we know which
|
||||||
// iteration of the loop we were on
|
// iteration of the loop we were on
|
||||||
std::string error_entry((_T(" '") + name + _T("'")).mb_str());
|
string error_entry((_T(" '") + name + _T("'")).mb_str());
|
||||||
std::string error_context(" failed for entry" + error_entry);
|
string error_context(" failed for entry" + error_entry);
|
||||||
|
|
||||||
TestEntries::iterator it = m_testEntries.find(name);
|
TestEntries::iterator it = m_testEntries.find(name);
|
||||||
CPPUNIT_ASSERT_MESSAGE(
|
CPPUNIT_ASSERT_MESSAGE(
|
||||||
@ -1140,7 +1169,7 @@ void ArchiveTestCase<Classes>::TestIterator(wxInputStream& in)
|
|||||||
typedef std::list<EntryT*> ArchiveCatalog;
|
typedef std::list<EntryT*> ArchiveCatalog;
|
||||||
typedef typename ArchiveCatalog::iterator CatalogIter;
|
typedef typename ArchiveCatalog::iterator CatalogIter;
|
||||||
|
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
#ifdef WXARC_MEMBER_TEMPLATES
|
#ifdef WXARC_MEMBER_TEMPLATES
|
||||||
@ -1152,7 +1181,7 @@ void ArchiveTestCase<Classes>::TestIterator(wxInputStream& in)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
|
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
|
||||||
std::auto_ptr<EntryT> entry(*it);
|
auto_ptr<EntryT> entry(*it);
|
||||||
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
|
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1169,7 +1198,7 @@ void ArchiveTestCase<Classes>::TestPairIterator(wxInputStream& in)
|
|||||||
typedef std::map<wxString, EntryT*> ArchiveCatalog;
|
typedef std::map<wxString, EntryT*> ArchiveCatalog;
|
||||||
typedef typename ArchiveCatalog::iterator CatalogIter;
|
typedef typename ArchiveCatalog::iterator CatalogIter;
|
||||||
|
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
#ifdef WXARC_MEMBER_TEMPLATES
|
#ifdef WXARC_MEMBER_TEMPLATES
|
||||||
@ -1177,11 +1206,11 @@ void ArchiveTestCase<Classes>::TestPairIterator(wxInputStream& in)
|
|||||||
#else
|
#else
|
||||||
ArchiveCatalog cat;
|
ArchiveCatalog cat;
|
||||||
for (PairIterT i(*arc); i != PairIterT(); ++i)
|
for (PairIterT i(*arc); i != PairIterT(); ++i)
|
||||||
cat.push_back(*i);
|
cat.insert(*i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
|
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
|
||||||
std::auto_ptr<EntryT> entry(it->second);
|
auto_ptr<EntryT> entry(it->second);
|
||||||
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
|
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,7 +1227,7 @@ void ArchiveTestCase<Classes>::TestSmartIterator(wxInputStream& in)
|
|||||||
typedef typename ArchiveCatalog::iterator CatalogIter;
|
typedef typename ArchiveCatalog::iterator CatalogIter;
|
||||||
typedef wxArchiveIterator<InputStreamT, Ptr<EntryT> > Iter;
|
typedef wxArchiveIterator<InputStreamT, Ptr<EntryT> > Iter;
|
||||||
|
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
|
|
||||||
#ifdef WXARC_MEMBER_TEMPLATES
|
#ifdef WXARC_MEMBER_TEMPLATES
|
||||||
ArchiveCatalog cat((Iter)*arc, Iter());
|
ArchiveCatalog cat((Iter)*arc, Iter());
|
||||||
@ -1224,14 +1253,14 @@ void ArchiveTestCase<Classes>::TestSmartPairIterator(wxInputStream& in)
|
|||||||
typedef wxArchiveIterator<InputStreamT,
|
typedef wxArchiveIterator<InputStreamT,
|
||||||
std::pair<wxString, Ptr<EntryT> > > PairIter;
|
std::pair<wxString, Ptr<EntryT> > > PairIter;
|
||||||
|
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
|
|
||||||
#ifdef WXARC_MEMBER_TEMPLATES
|
#ifdef WXARC_MEMBER_TEMPLATES
|
||||||
ArchiveCatalog cat((PairIter)*arc, PairIter());
|
ArchiveCatalog cat((PairIter)*arc, PairIter());
|
||||||
#else
|
#else
|
||||||
ArchiveCatalog cat;
|
ArchiveCatalog cat;
|
||||||
for (PairIter i(*arc); i != PairIter(); ++i)
|
for (PairIter i(*arc); i != PairIter(); ++i)
|
||||||
cat.push_back(*i);
|
cat.insert(*i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_ASSERT(m_testEntries.size() == cat.size());
|
CPPUNIT_ASSERT(m_testEntries.size() == cat.size());
|
||||||
@ -1251,8 +1280,8 @@ void ArchiveTestCase<Classes>::ReadSimultaneous(TestInputStream& in)
|
|||||||
|
|
||||||
// create two archive input streams
|
// create two archive input streams
|
||||||
TestInputStream in2(in);
|
TestInputStream in2(in);
|
||||||
std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
|
||||||
std::auto_ptr<InputStreamT> arc2(m_factory->NewStream(in2));
|
auto_ptr<InputStreamT> arc2(m_factory->NewStream(in2));
|
||||||
|
|
||||||
// load the catalog
|
// load the catalog
|
||||||
#ifdef WXARC_MEMBER_TEMPLATES
|
#ifdef WXARC_MEMBER_TEMPLATES
|
||||||
@ -1260,7 +1289,7 @@ void ArchiveTestCase<Classes>::ReadSimultaneous(TestInputStream& in)
|
|||||||
#else
|
#else
|
||||||
ArchiveCatalog cat;
|
ArchiveCatalog cat;
|
||||||
for (PairIter i(*arc); i != PairIter(); ++i)
|
for (PairIter i(*arc); i != PairIter(); ++i)
|
||||||
cat.push_back(*i);
|
cat.insert(*i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// the names of two entries to read
|
// the names of two entries to read
|
||||||
@ -1330,7 +1359,7 @@ void ArchiveTestCase<Classes>::OnSetNotifier(EntryT& entry)
|
|||||||
class ZipTestCase : public ArchiveTestCase<ZipClasses>
|
class ZipTestCase : public ArchiveTestCase<ZipClasses>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZipTestCase(const wxString& name,
|
ZipTestCase(string name,
|
||||||
int id,
|
int id,
|
||||||
int options,
|
int options,
|
||||||
const wxString& archiver = wxEmptyString,
|
const wxString& archiver = wxEmptyString,
|
||||||
@ -1408,8 +1437,9 @@ void ZipTestCase::OnEntryExtracted(wxZipEntry& entry,
|
|||||||
{
|
{
|
||||||
// provide some context for the error message so that we know which
|
// provide some context for the error message so that we know which
|
||||||
// iteration of the loop we were on
|
// iteration of the loop we were on
|
||||||
std::string error_entry((_T(" '") + entry.GetName() + _T("'")).mb_str());
|
wxString name = _T(" '") + entry.GetName() + _T("'");
|
||||||
std::string error_context(" failed for entry" + error_entry);
|
string error_entry(name.mb_str());
|
||||||
|
string error_context(" failed for entry" + error_entry);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_MESSAGE("GetComment" + error_context,
|
CPPUNIT_ASSERT_MESSAGE("GetComment" + error_context,
|
||||||
entry.GetComment() == testEntry.GetComment());
|
entry.GetComment() == testEntry.GetComment());
|
||||||
@ -1456,8 +1486,8 @@ void ZipTestCase::OnSetNotifier(EntryT& entry)
|
|||||||
class ZipPipeTestCase : public CppUnit::TestCase
|
class ZipPipeTestCase : public CppUnit::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZipPipeTestCase(const wxString& name, int options) :
|
ZipPipeTestCase(string name, int options) :
|
||||||
CppUnit::TestCase(std::string(name.mb_str())), m_options(options) { }
|
CppUnit::TestCase(name), m_options(options) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void runTest();
|
void runTest();
|
||||||
@ -1480,7 +1510,7 @@ void ZipPipeTestCase::runTest()
|
|||||||
TestInputStream in(out);
|
TestInputStream in(out);
|
||||||
wxZipInputStream zip(in);
|
wxZipInputStream zip(in);
|
||||||
|
|
||||||
std::auto_ptr<wxZipEntry> entry(zip.GetNextEntry());
|
auto_ptr<wxZipEntry> entry(zip.GetNextEntry());
|
||||||
CPPUNIT_ASSERT(entry.get() != NULL);
|
CPPUNIT_ASSERT(entry.get() != NULL);
|
||||||
|
|
||||||
if ((m_options & PipeIn) == 0)
|
if ((m_options & PipeIn) == 0)
|
||||||
@ -1516,7 +1546,7 @@ private:
|
|||||||
void AddCmd(wxArrayString& cmdlist, const wxString& cmd);
|
void AddCmd(wxArrayString& cmdlist, const wxString& cmd);
|
||||||
bool IsInPath(const wxString& cmd);
|
bool IsInPath(const wxString& cmd);
|
||||||
|
|
||||||
wxString Description(const wxString& type,
|
string Description(const wxString& type,
|
||||||
int options,
|
int options,
|
||||||
bool genericInterface = false,
|
bool genericInterface = false,
|
||||||
const wxString& archiver = wxEmptyString,
|
const wxString& archiver = wxEmptyString,
|
||||||
@ -1574,7 +1604,7 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
|
|||||||
if ((options & PipeOut) && !j->empty())
|
if ((options & PipeOut) && !j->empty())
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
wxString name = Description(_T("wxZip"), options,
|
string name = Description(_T("wxZip"), options,
|
||||||
genInterface != 0, *j, *i);
|
genInterface != 0, *j, *i);
|
||||||
|
|
||||||
if (genInterface)
|
if (genInterface)
|
||||||
@ -1592,7 +1622,7 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
|
|||||||
// if have popen then can check the piped output of 'zip - -'
|
// if have popen then can check the piped output of 'zip - -'
|
||||||
if (IsInPath(_T("zip")))
|
if (IsInPath(_T("zip")))
|
||||||
for (int options = 0; options <= PipeIn; options += PipeIn) {
|
for (int options = 0; options <= PipeIn; options += PipeIn) {
|
||||||
wxString name = Description(_T("ZipPipeTestCase"), options);
|
string name = Description(_T("ZipPipeTestCase"), options);
|
||||||
addTest(new ZipPipeTestCase(name, options));
|
addTest(new ZipPipeTestCase(name, options));
|
||||||
m_id++;
|
m_id++;
|
||||||
}
|
}
|
||||||
@ -1603,7 +1633,7 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
|
|||||||
|
|
||||||
// make a display string for the option bits
|
// make a display string for the option bits
|
||||||
//
|
//
|
||||||
wxString ArchiveTestSuite::Description(const wxString& type,
|
string ArchiveTestSuite::Description(const wxString& type,
|
||||||
int options,
|
int options,
|
||||||
bool genericInterface,
|
bool genericInterface,
|
||||||
const wxString& archiver,
|
const wxString& archiver,
|
||||||
@ -1635,7 +1665,7 @@ wxString ArchiveTestSuite::Description(const wxString& type,
|
|||||||
|
|
||||||
descr << optstr;
|
descr << optstr;
|
||||||
|
|
||||||
return descr;
|
return (const char*)descr.mb_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// register in the unnamed registry so that these tests are run by default
|
// register in the unnamed registry so that these tests are run by default
|
||||||
|
Loading…
Reference in New Issue
Block a user