]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/archive/archivetest.cpp
Rebaked test.bkl for new tests largefile, size, point
[wxWidgets.git] / tests / archive / archivetest.cpp
index 476513e4f4df72e5306fcaef1a1d11c0ba3d5f63..5a3a10aafd795ba5f402688b050fad0c5909f999 100644 (file)
@@ -7,7 +7,7 @@
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "wx/wxprec.h"
+#include "testprec.h"
 
 #ifdef __BORLANDC__
 #   pragma hdrstop
 
 #define WX_TEST_ARCHIVE_ITERATOR
 
+// VC++ 6 warns that the list iterator's '->' operator will not work whenever
+// std::list is used with a non-pointer, so switch it off.
+#if defined _MSC_VER && _MSC_VER < 1300
+#pragma warning (disable:4284)
+#endif
+
 #include "wx/zipstrm.h"
 #include "wx/mstream.h"
 #include "wx/wfstream.h"
 #include "wx/dir.h"
-#include "wx/cppunit.h"
 #include <string>
 #include <list>
+#include <map>
 #include <sys/stat.h>
 
+using std::string;
+using std::auto_ptr;
+
+
 // Check whether member templates can be used
 //
 #if defined __GNUC__ && \
@@ -119,7 +129,7 @@ public:
 private:
     wxDateTime m_dt;
     size_t m_len;
-    const char *m_data;
+    char *m_data;
     wxString m_comment;
     bool m_isText;
 };
@@ -129,9 +139,8 @@ TestEntry::TestEntry(const wxDateTime& dt, int len, const char *data)
     m_len(len),
     m_isText(len > 0)
 {
-    char *d = new char[len];
-    memcpy(d, data, len);
-    m_data = d;
+    m_data = new char[len];
+    memcpy(m_data, data, len);
 
     for (int i = 0; i < len && m_isText; i++)
         m_isText = (signed char)m_data[i] > 0;
@@ -153,7 +162,7 @@ public:
     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);
+    void GetData(char*& data, size_t& size);
 
     enum { STUB_SIZE = 2048, INITIAL_SIZE = 0x18000, SEEK_LIMIT = 0x100000 };
 
@@ -201,7 +210,7 @@ wxFileOffset TestOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
         }
         if (pos < 0 || pos > SEEK_LIMIT)
             return wxInvalidOffset;
-        m_pos = pos;
+        m_pos = (size_t)pos;
         return m_pos;
     }
     return wxInvalidOffset;
@@ -222,7 +231,7 @@ size_t TestOutputStream::OnSysWrite(const void *buffer, size_t size)
     wxCHECK(newsize > m_pos, 0);
 
     if (m_capacity < newsize) {
-        size_t capacity = m_capacity ? m_capacity : INITIAL_SIZE;
+        size_t capacity = m_capacity ? m_capacity : (size_t)INITIAL_SIZE;
 
         while (capacity < newsize) {
             capacity <<= 1;
@@ -246,7 +255,7 @@ size_t TestOutputStream::OnSysWrite(const void *buffer, size_t size)
     return size;
 }
 
-void TestOutputStream::GetData(const char*& data, size_t& size)
+void TestOutputStream::GetData(char*& data, size_t& size)
 {
     data = m_data;
     size = m_size;
@@ -293,17 +302,17 @@ private:
     int m_options;
     size_t m_pos;
     size_t m_size;
-    const char *m_data;
+    char *m_data;
 };
 
 TestInputStream::TestInputStream(const TestInputStream& in)
-  : m_options(in.m_options),
+  : wxInputStream(),
+    m_options(in.m_options),
     m_pos(in.m_pos),
     m_size(in.m_size)
 {
-    char *p = new char[m_size];
-    memcpy(p, in.m_data, m_size);
-    m_data = p;
+    m_data = new char[m_size];
+    memcpy(m_data, in.m_data, m_size);
 }
 
 void TestInputStream::Rewind()
@@ -340,7 +349,7 @@ wxFileOffset TestInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
         }
         if (pos < 0 || pos > TestOutputStream::SEEK_LIMIT)
             return wxInvalidOffset;
-        m_pos = pos;
+        m_pos = (size_t)pos;
         return m_pos;
     }
     return wxInvalidOffset;
@@ -527,9 +536,9 @@ template <class Classes>
 class ArchiveTestCase : public CppUnit::TestCase
 {
 public:
-    ArchiveTestCase(const wxString& name,
+    ArchiveTestCase(string name,
                     int id,
-                    typename Classes::ClassFactoryT *factory,
+                    wxArchiveClassFactory *factory,
                     int options,
                     const wxString& archiver = wxEmptyString,
                     const wxString& unarchiver = wxEmptyString);
@@ -592,7 +601,7 @@ protected:
 
     typedef std::map<wxString, TestEntry*> TestEntries;
     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
     wxDateTime m_timeStamp;                 // timestamp to give test entries
     int m_id;                               // select between the possibilites
@@ -600,21 +609,32 @@ protected:
     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>
-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),
+ArchiveTestCase<Classes>::ArchiveTestCase(
+    string name,
+    int id,
+    wxArchiveClassFactory *factory,
+    int options,
+    const wxString& archiver,
+    const wxString& unarchiver)
+  :
+    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_timeStamp(1, wxDateTime::Mar, 2005, 12, 0),
     m_id(id),
     m_archiver(archiver),
     m_unarchiver(unarchiver)
 {
+    wxASSERT(m_factory.get() != NULL);
 }
 
 template <class Classes>
@@ -663,7 +683,7 @@ void ArchiveTestCase<Classes>::runTest()
         ExtractArchive(in);
     else
         ExtractArchive(in, m_unarchiver);
-    
+
     // check that all the test entries were found in the archive
     CPPUNIT_ASSERT(m_testEntries.empty());
 }
@@ -713,7 +733,7 @@ TestEntry& ArchiveTestCase<Classes>::Add(const char *name,
 {
     wxCharBuffer buf(len);
     for (int i = 0; i < len; i++)
-        buf.data()[i] = value == EOF ? rand() : value;
+        buf.data()[i] = (char)(value == EOF ? rand() : value);
     return Add(name, buf, len);
 }
 
@@ -722,7 +742,7 @@ TestEntry& ArchiveTestCase<Classes>::Add(const char *name,
 template <class Classes>
 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;
 
     OnCreateArchive(*arc);
@@ -745,12 +765,12 @@ void ArchiveTestCase<Classes>::CreateArchive(wxOutputStream& out)
 
         // provide some context for the error message so that we know which
         // iteration of the loop we were on
-        std::string error_entry((_T(" '") + name + _T("'")).mb_str());
-        std::string error_context(" failed for entry" + error_entry);
+        string error_entry((_T(" '") + name + _T("'")).mb_str());
+        string error_context(" failed for entry" + error_entry);
 
         if ((choices & 2) || testEntry.IsText()) {
             // try PutNextEntry(EntryT *pEntry)
-            std::auto_ptr<EntryT> entry(m_factory->NewEntry());
+            auto_ptr<EntryT> entry(m_factory->NewEntry());
             entry->SetName(name, wxPATH_UNIX);
             if (setIsDir)
                 entry->SetIsDir();
@@ -861,9 +881,9 @@ template <class Classes>
 void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
                                              wxOutputStream& out)
 {
-    std::auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
-    std::auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
-    std::auto_ptr<EntryT> entry;
+    auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
+    auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
+    EntryT *pEntry;
 
     const wxString deleteName = _T("bin/bin1000");
     const wxString renameFrom = _T("zero/zero1024");
@@ -873,14 +893,15 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
 
     arcOut->CopyArchiveMetaData(*arcIn);
 
-    while (entry.reset(arcIn->GetNextEntry()), entry.get() != NULL) {
+    while ((pEntry = arcIn->GetNextEntry()) != NULL) {
+        auto_ptr<EntryT> entry(pEntry);
         OnSetNotifier(*entry);
         wxString name = entry->GetName(wxPATH_UNIX);
 
         // provide some context for the error message so that we know which
         // iteration of the loop we were on
-        std::string error_entry((_T(" '") + name + _T("'")).mb_str());
-        std::string error_context(" failed for entry" + error_entry);
+        string error_entry((_T(" '") + name + _T("'")).mb_str());
+        string error_context(" failed for entry" + error_entry);
 
         if (name == deleteName) {
             TestEntries::iterator it = m_testEntries.find(name);
@@ -918,13 +939,13 @@ void ArchiveTestCase<Classes>::ModifyArchive(wxInputStream& in,
 
     // try adding a new entry
     TestEntry& testEntry = Add(newName.mb_str(), newData);
-    entry.reset(m_factory->NewEntry());
-    entry->SetName(newName);
-    entry->SetDateTime(testEntry.GetDateTime());
-    entry->SetSize(testEntry.GetLength());
-    OnCreateEntry(*arcOut, testEntry, entry.get());
-    OnSetNotifier(*entry);
-    CPPUNIT_ASSERT(arcOut->PutNextEntry(entry.release()));
+    auto_ptr<EntryT> newentry(m_factory->NewEntry());
+    newentry->SetName(newName);
+    newentry->SetDateTime(testEntry.GetDateTime());
+    newentry->SetSize(testEntry.GetLength());
+    OnCreateEntry(*arcOut, testEntry, newentry.get());
+    OnSetNotifier(*newentry);
+    CPPUNIT_ASSERT(arcOut->PutNextEntry(newentry.release()));
     CPPUNIT_ASSERT(arcOut->Write(newData, strlen(newData)).IsOk());
 
     // should work with or without explicit Close
@@ -941,7 +962,7 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
     typedef std::list<EntryPtr> Entries;
     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();
     EntryPtr entry;
     Entries entries;
@@ -954,8 +975,8 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in)
 
         // provide some context for the error message so that we know which
         // iteration of the loop we were on
-        std::string error_entry((_T(" '") + name + _T("'")).mb_str());
-        std::string error_context(" failed for entry" + error_entry);
+        string error_entry((_T(" '") + name + _T("'")).mb_str());
+        string error_context(" failed for entry" + error_entry);
 
         TestEntries::iterator it = m_testEntries.find(name);
         CPPUNIT_ASSERT_MESSAGE(
@@ -1040,7 +1061,7 @@ void ArchiveTestCase<Classes>::ExtractArchive(wxInputStream& in,
         wxFileName fn(tmpdir.GetName());
         fn.SetExt(_T("arc"));
         wxString tmparc = fn.GetFullPath();
-        
+
         if (m_options & Stub)
             in.SeekI(TestOutputStream::STUB_SIZE * 2);
 
@@ -1092,8 +1113,8 @@ void ArchiveTestCase<Classes>::VerifyDir(wxString& path, size_t rootlen /*=0*/)
 
             // provide some context for the error message so that we know which
             // iteration of the loop we were on
-            std::string error_entry((_T(" '") + name + _T("'")).mb_str());
-            std::string error_context(" failed for entry" + error_entry);
+            string error_entry((_T(" '") + name + _T("'")).mb_str());
+            string error_context(" failed for entry" + error_entry);
 
             TestEntries::iterator it = m_testEntries.find(name);
             CPPUNIT_ASSERT_MESSAGE(
@@ -1113,7 +1134,7 @@ void ArchiveTestCase<Classes>::VerifyDir(wxString& path, size_t rootlen /*=0*/)
                 CPPUNIT_ASSERT_MESSAGE(
                     "entry not found in archive" + error_entry, in.Ok());
 
-                size_t size = in.GetLength();
+                size_t size = (size_t)in.GetLength();
                 wxCharBuffer buf(size);
                 CPPUNIT_ASSERT_MESSAGE("Read" + error_context,
                     in.Read(buf.data(), size).LastRead() == size);
@@ -1141,7 +1162,7 @@ void ArchiveTestCase<Classes>::TestIterator(wxInputStream& in)
     typedef std::list<EntryT*> ArchiveCatalog;
     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;
 
 #ifdef WXARC_MEMBER_TEMPLATES
@@ -1153,7 +1174,7 @@ void ArchiveTestCase<Classes>::TestIterator(wxInputStream& in)
 #endif
 
     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));
     }
 
@@ -1170,7 +1191,7 @@ void ArchiveTestCase<Classes>::TestPairIterator(wxInputStream& in)
     typedef std::map<wxString, EntryT*> ArchiveCatalog;
     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;
 
 #ifdef WXARC_MEMBER_TEMPLATES
@@ -1178,11 +1199,11 @@ void ArchiveTestCase<Classes>::TestPairIterator(wxInputStream& in)
 #else
     ArchiveCatalog cat;
     for (PairIterT i(*arc); i != PairIterT(); ++i)
-        cat.push_back(*i);
+        cat.insert(*i);
 #endif
 
     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));
     }
 
@@ -1199,7 +1220,7 @@ void ArchiveTestCase<Classes>::TestSmartIterator(wxInputStream& in)
     typedef typename ArchiveCatalog::iterator CatalogIter;
     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
     ArchiveCatalog cat((Iter)*arc, Iter());
@@ -1220,25 +1241,31 @@ void ArchiveTestCase<Classes>::TestSmartIterator(wxInputStream& in)
 template <class Classes>
 void ArchiveTestCase<Classes>::TestSmartPairIterator(wxInputStream& in)
 {
+#if defined _MSC_VER && defined _MSC_VER < 1200
+    // With VC++ 5.0 the '=' operator of std::pair breaks when the second
+    // type is Ptr<EntryT>, so this iterator can't be made to work.
+    (void)in;
+#else
     typedef std::map<wxString, Ptr<EntryT> > ArchiveCatalog;
     typedef typename ArchiveCatalog::iterator CatalogIter;
     typedef wxArchiveIterator<InputStreamT,
                 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
     ArchiveCatalog cat((PairIter)*arc, PairIter());
 #else
     ArchiveCatalog cat;
     for (PairIter i(*arc); i != PairIter(); ++i)
-        cat.push_back(*i);
+        cat.insert(*i);
 #endif
 
     CPPUNIT_ASSERT(m_testEntries.size() == cat.size());
 
     for (CatalogIter it = cat.begin(); it != cat.end(); ++it)
         CPPUNIT_ASSERT(m_testEntries.count(it->second->GetName(wxPATH_UNIX)));
+#endif
 }
 
 // try reading two entries at the same time
@@ -1252,8 +1279,8 @@ void ArchiveTestCase<Classes>::ReadSimultaneous(TestInputStream& in)
 
     // create two archive input streams
     TestInputStream in2(in);
-    std::auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
-    std::auto_ptr<InputStreamT> arc2(m_factory->NewStream(in2));
+    auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
+    auto_ptr<InputStreamT> arc2(m_factory->NewStream(in2));
 
     // load the catalog
 #ifdef WXARC_MEMBER_TEMPLATES
@@ -1261,7 +1288,7 @@ void ArchiveTestCase<Classes>::ReadSimultaneous(TestInputStream& in)
 #else
     ArchiveCatalog cat;
     for (PairIter i(*arc); i != PairIter(); ++i)
-        cat.push_back(*i);
+        cat.insert(*i);
 #endif
 
     // the names of two entries to read
@@ -1331,7 +1358,7 @@ void ArchiveTestCase<Classes>::OnSetNotifier(EntryT& entry)
 class ZipTestCase : public ArchiveTestCase<ZipClasses>
 {
 public:
-    ZipTestCase(const wxString& name,
+    ZipTestCase(string name,
                 int id,
                 int options,
                 const wxString& archiver = wxEmptyString,
@@ -1344,13 +1371,13 @@ public:
 
 protected:
     void OnCreateArchive(wxZipOutputStream& zip);
-    
+
     void OnArchiveExtracted(wxZipInputStream& zip, int expectedTotal);
-    
+
     void OnCreateEntry(wxZipOutputStream& zip,
                        TestEntry& testEntry,
                        wxZipEntry *entry);
-    
+
     void OnEntryExtracted(wxZipEntry& entry,
                           const TestEntry& testEntry,
                           wxZipInputStream *arc);
@@ -1409,8 +1436,9 @@ void ZipTestCase::OnEntryExtracted(wxZipEntry& entry,
 {
     // provide some context for the error message so that we know which
     // iteration of the loop we were on
-    std::string error_entry((_T(" '") + entry.GetName() + _T("'")).mb_str());
-    std::string error_context(" failed for entry" + error_entry);
+    wxString name = _T(" '") + entry.GetName() + _T("'");
+    string error_entry(name.mb_str());
+    string error_context(" failed for entry" + error_entry);
 
     CPPUNIT_ASSERT_MESSAGE("GetComment" + error_context,
         entry.GetComment() == testEntry.GetComment());
@@ -1457,8 +1485,8 @@ void ZipTestCase::OnSetNotifier(EntryT& entry)
 class ZipPipeTestCase : public CppUnit::TestCase
 {
 public:
-    ZipPipeTestCase(const wxString& name, int options) :
-        CppUnit::TestCase(std::string(name.mb_str())), m_options(options) { }
+    ZipPipeTestCase(string name, int options) :
+        CppUnit::TestCase(name), m_options(options) { }
 
 protected:
     void runTest();
@@ -1481,7 +1509,7 @@ void ZipPipeTestCase::runTest()
     TestInputStream in(out);
     wxZipInputStream zip(in);
 
-    std::auto_ptr<wxZipEntry> entry(zip.GetNextEntry());
+    auto_ptr<wxZipEntry> entry(zip.GetNextEntry());
     CPPUNIT_ASSERT(entry.get() != NULL);
 
     if ((m_options & PipeIn) == 0)
@@ -1517,11 +1545,11 @@ private:
     void AddCmd(wxArrayString& cmdlist, const wxString& cmd);
     bool IsInPath(const wxString& cmd);
 
-    wxString Description(const wxString& type,
-                         int options,
-                         bool genericInterface = false,
-                         const wxString& archiver = wxEmptyString,
-                         const wxString& unarchiver = wxEmptyString);
+    string Description(const wxString& type,
+                       int options,
+                       bool genericInterface = false,
+                       const wxString& archiver = wxEmptyString,
+                       const wxString& unarchiver = wxEmptyString);
 };
 
 ArchiveTestSuite::ArchiveTestSuite()
@@ -1570,13 +1598,13 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
                     // unzip doesn't support piping in the zip
                     if ((options & PipeIn) && !i->empty())
                         continue;
-#ifdef WXARC_NO_POPEN 
+#ifdef WXARC_NO_POPEN
                     // if no popen then can use piped output of zip
                     if ((options & PipeOut) && !j->empty())
                         continue;
 #endif
-                    wxString name = Description(_T("wxZip"), options, 
-                                                genInterface != 0, *j, *i);
+                    string name = Description(_T("wxZip"), options,
+                                              genInterface != 0, *j, *i);
 
                     if (genInterface)
                         addTest(new ArchiveTestCase<ArchiveClasses>(
@@ -1589,11 +1617,11 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
                     m_id++;
                 }
 
-#ifndef WXARC_NO_POPEN 
+#ifndef WXARC_NO_POPEN
     // if have popen then can check the piped output of 'zip - -'
     if (IsInPath(_T("zip")))
         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));
             m_id++;
         }
@@ -1604,15 +1632,15 @@ ArchiveTestSuite *ArchiveTestSuite::makeSuite()
 
 // make a display string for the option bits
 //
-wxString ArchiveTestSuite::Description(const wxString& type,
-                                       int options,
-                                       bool genericInterface,
-                                       const wxString& archiver,
-                                       const wxString& unarchiver)
+string ArchiveTestSuite::Description(const wxString& type,
+                                     int options,
+                                     bool genericInterface,
+                                     const wxString& archiver,
+                                     const wxString& unarchiver)
 {
     wxString descr;
     descr << m_id << _T(" ");
-    
+
     if (genericInterface)
         descr << _T("wxArchive (") << type << _T(")");
     else
@@ -1622,7 +1650,7 @@ wxString ArchiveTestSuite::Description(const wxString& type,
         descr << _T(" ") << archiver.BeforeFirst(_T(' '));
     if (!unarchiver.empty())
         descr << _T(" ") << unarchiver.BeforeFirst(_T(' '));
-    
+
     wxString optstr;
 
     if ((options & PipeIn) != 0)
@@ -1636,7 +1664,7 @@ wxString ArchiveTestSuite::Description(const wxString& type,
 
     descr << optstr;
 
-    return descr;
+    return (const char*)descr.mb_str();
 }
 
 // register in the unnamed registry so that these tests are run by default