1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        tests/streams/zlibstream.cpp
3 // Purpose:     Test wxZlibInputStream/wxZlibOutputStream
4 // Author:      Hans Van Leemputten
5 // Copyright:   (c) 2004 Hans Van Leemputten
6 // Licence:     wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
8 
9 // For compilers that support precompilation, includes "wx/wx.h".
10 // and "wx/cppunit.h"
11 #include "testprec.h"
12 
13 
14 // for all others, include the necessary headers
15 #ifndef WX_PRECOMP
16     #include "wx/wx.h"
17 #endif
18 
19 #include "wx/zstream.h"
20 #include "wx/wfstream.h"
21 #include "wx/mstream.h"
22 #include "wx/txtstrm.h"
23 #include "wx/buffer.h"
24 
25 #include "bstream.h"
26 
27 using std::string;
28 
29 #define DATABUFFER_SIZE 1024
30 
31 static const wxString FILENAME_GZ = wxT("zlibtest.gz");
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 // The test case
35 //
36 // Try to fully test wxZlibInputStream and wxZlibOutputStream
37 
38 class zlibStream : public BaseStreamTestCase<wxZlibInputStream, wxZlibOutputStream>
39 {
40 public:
41     zlibStream();
42     virtual ~zlibStream();
43 
44     CPPUNIT_TEST_SUITE(zlibStream);
45         // Base class stream tests the zlibstream supports.
46         CPPUNIT_TEST(Input_GetSizeFail);
47         CPPUNIT_TEST(Input_GetC);
48         CPPUNIT_TEST(Input_Read);
49         CPPUNIT_TEST(Input_Eof);
50         CPPUNIT_TEST(Input_LastRead);
51         CPPUNIT_TEST(Input_CanRead);
52         CPPUNIT_TEST(Input_SeekIFail);
53         CPPUNIT_TEST(Input_TellI);
54         CPPUNIT_TEST(Input_Peek);
55         CPPUNIT_TEST(Input_Ungetch);
56 
57         CPPUNIT_TEST(Output_PutC);
58         CPPUNIT_TEST(Output_Write);
59         CPPUNIT_TEST(Output_LastWrite);
60         CPPUNIT_TEST(Output_SeekOFail);
61         CPPUNIT_TEST(Output_TellO);
62 
63         // Other test specific for zlib stream test case.
64         CPPUNIT_TEST(TestStream_NoHeader_Default);
65         CPPUNIT_TEST(TestStream_NoHeader_NoComp);
66         CPPUNIT_TEST(TestStream_NoHeader_SpeedComp);
67         CPPUNIT_TEST(TestStream_NoHeader_BestComp);
68         CPPUNIT_TEST(TestStream_NoHeader_Dictionary);
69         CPPUNIT_TEST(TestStream_ZLib_Default);
70         CPPUNIT_TEST(TestStream_ZLib_NoComp);
71         CPPUNIT_TEST(TestStream_ZLib_SpeedComp);
72         CPPUNIT_TEST(TestStream_ZLib_BestComp);
73         CPPUNIT_TEST(TestStream_GZip_Default);
74         CPPUNIT_TEST(TestStream_GZip_NoComp);
75         CPPUNIT_TEST(TestStream_GZip_SpeedComp);
76         CPPUNIT_TEST(TestStream_GZip_BestComp);
77         CPPUNIT_TEST(TestStream_GZip_Dictionary);
78         CPPUNIT_TEST(TestStream_ZLibGZip);
79         CPPUNIT_TEST(Decompress_BadData);
80         CPPUNIT_TEST(Decompress_wx251_zlib114_Data_NoHeader);
81         CPPUNIT_TEST(Decompress_wx251_zlib114_Data_ZLib);
82         CPPUNIT_TEST(Decompress_gzip135Data);
83     CPPUNIT_TEST_SUITE_END();
84 
85 protected:
86     // Test different stream construct settings.
87     void TestStream_NoHeader_Default();
88     void TestStream_NoHeader_NoComp();
89     void TestStream_NoHeader_SpeedComp();
90     void TestStream_NoHeader_BestComp();
91     void TestStream_NoHeader_Dictionary();
92     void TestStream_ZLib_Default();
93     void TestStream_ZLib_NoComp();
94     void TestStream_ZLib_SpeedComp();
95     void TestStream_ZLib_BestComp();
96     void TestStream_GZip_Default();
97     void TestStream_GZip_NoComp();
98     void TestStream_GZip_SpeedComp();
99     void TestStream_GZip_BestComp();
100     void TestStream_GZip_Dictionary();
101     void TestStream_ZLibGZip();
102     // Try to decompress bad data.
103     void Decompress_BadData();
104     // Decompress data that was compress by an external app.
105     // (like test wx 2.4.2, 2.5.1 and gzip data)
106     // Note: This test is limited in testing range!
107     void Decompress_wx251_zlib114_Data_NoHeader();
108     void Decompress_wx251_zlib114_Data_ZLib();
109     void Decompress_gzip135Data();
110 
111 private:
112     const char *GetDataBuffer();
113     const unsigned char *GetCompressedData();
114     void doTestStreamData(int input_flag, int output_flag, int compress_level, const wxMemoryBuffer *buf = NULL);
115     void doDecompress_ExternalData(const unsigned char *data, const char *value, size_t data_size, size_t value_size, int flag = wxZLIB_AUTO);
116 
117 private:
118     // Implement base class functions.
119     virtual wxZlibInputStream  *DoCreateInStream() wxOVERRIDE;
120     virtual wxZlibOutputStream *DoCreateOutStream() wxOVERRIDE;
121     virtual void DoDeleteInStream() wxOVERRIDE;
122     virtual void DoDeleteOutStream() wxOVERRIDE;
123 
124     // Helper that can be used to create new wx compatibility tests...
125     // Otherwise not used by the tests.
126     void genExtTestData(wxTextOutputStream &out, const char *buf, int flag);
127 
128 private:
129     char            m_DataBuffer[DATABUFFER_SIZE];
130     size_t          m_SizeCompressedData;
131     unsigned char  *m_pCompressedData;
132     wxMemoryBuffer  m_Dictionary;
133 
134     // Used by the base Creat[In|Out]Stream and Delete[In|Out]Stream.
135     wxMemoryInputStream  *m_pTmpMemInStream;
136     wxMemoryOutputStream *m_pTmpMemOutStream;
137 };
138 
zlibStream()139 zlibStream::zlibStream()
140     :m_SizeCompressedData(0),
141      m_pCompressedData(NULL),
142      m_pTmpMemInStream(NULL),
143      m_pTmpMemOutStream(NULL)
144 {
145     // Init the data buffer.
146     for (size_t i = 0; i < DATABUFFER_SIZE; i++)
147         m_DataBuffer[i] = (i % 0xFF);
148 
149     m_Dictionary.AppendData(m_DataBuffer, sizeof(m_DataBuffer) / 2);
150 
151     // Set extra base config settings.
152     m_bSimpleTellITest = true;
153     m_bSimpleTellOTest = true;
154 
155 /* Example code on how to produce test data...
156     {
157         wxFFileOutputStream fstream_out(wxT("gentest.cpp"));
158         wxTextOutputStream out( fstream_out );
159 
160         genExtTestData(out, "zlib data created with wxWidgets 2.5.x [March 27], wxZLIB_NO_HEADER, zlib 1.1.4", wxZLIB_NO_HEADER);
161         genExtTestData(out, "zlib data created with wxWidgets 2.5.x [March 27], wxZLIB_ZLIB, zlib 1.1.4", wxZLIB_ZLIB);
162     }
163 */
164 }
165 
~zlibStream()166 zlibStream::~zlibStream()
167 {
168     delete[] m_pCompressedData;
169 
170     delete m_pTmpMemInStream;
171     delete m_pTmpMemOutStream;
172 }
173 
TestStream_NoHeader_Default()174 void zlibStream::TestStream_NoHeader_Default()
175 {
176     doTestStreamData(wxZLIB_NO_HEADER, wxZLIB_NO_HEADER, wxZ_DEFAULT_COMPRESSION);
177 }
TestStream_NoHeader_NoComp()178 void zlibStream::TestStream_NoHeader_NoComp()
179 {
180     doTestStreamData(wxZLIB_NO_HEADER, wxZLIB_NO_HEADER, wxZ_NO_COMPRESSION);
181 }
TestStream_NoHeader_SpeedComp()182 void zlibStream::TestStream_NoHeader_SpeedComp()
183 {
184     doTestStreamData(wxZLIB_NO_HEADER, wxZLIB_NO_HEADER, wxZ_BEST_SPEED);
185 }
TestStream_NoHeader_BestComp()186 void zlibStream::TestStream_NoHeader_BestComp()
187 {
188     doTestStreamData(wxZLIB_NO_HEADER, wxZLIB_NO_HEADER, wxZ_BEST_COMPRESSION);
189 }
TestStream_NoHeader_Dictionary()190 void zlibStream::TestStream_NoHeader_Dictionary()
191 {
192     doTestStreamData(wxZLIB_NO_HEADER, wxZLIB_NO_HEADER, wxZ_DEFAULT_COMPRESSION, &m_Dictionary);
193 }
194 
TestStream_ZLib_Default()195 void zlibStream::TestStream_ZLib_Default()
196 {
197     doTestStreamData(wxZLIB_ZLIB, wxZLIB_ZLIB, wxZ_DEFAULT_COMPRESSION);
198 }
TestStream_ZLib_NoComp()199 void zlibStream::TestStream_ZLib_NoComp()
200 {
201     doTestStreamData(wxZLIB_ZLIB, wxZLIB_ZLIB, wxZ_NO_COMPRESSION);
202 }
TestStream_ZLib_SpeedComp()203 void zlibStream::TestStream_ZLib_SpeedComp()
204 {
205     doTestStreamData(wxZLIB_ZLIB, wxZLIB_ZLIB, wxZ_BEST_SPEED);
206 }
TestStream_ZLib_BestComp()207 void zlibStream::TestStream_ZLib_BestComp()
208 {
209     doTestStreamData(wxZLIB_ZLIB, wxZLIB_ZLIB, wxZ_BEST_COMPRESSION);
210 }
211 
TestStream_GZip_Default()212 void zlibStream::TestStream_GZip_Default()
213 {
214     doTestStreamData(wxZLIB_GZIP, wxZLIB_GZIP, wxZ_DEFAULT_COMPRESSION);
215 }
TestStream_GZip_NoComp()216 void zlibStream::TestStream_GZip_NoComp()
217 {
218     doTestStreamData(wxZLIB_GZIP, wxZLIB_GZIP, wxZ_NO_COMPRESSION);
219 }
TestStream_GZip_SpeedComp()220 void zlibStream::TestStream_GZip_SpeedComp()
221 {
222     doTestStreamData(wxZLIB_GZIP, wxZLIB_GZIP, wxZ_BEST_SPEED);
223 }
TestStream_GZip_BestComp()224 void zlibStream::TestStream_GZip_BestComp()
225 {
226     doTestStreamData(wxZLIB_GZIP, wxZLIB_GZIP, wxZ_BEST_COMPRESSION);
227 }
TestStream_GZip_Dictionary()228 void zlibStream::TestStream_GZip_Dictionary()
229 {
230     doTestStreamData(wxZLIB_GZIP, wxZLIB_GZIP, wxZ_DEFAULT_COMPRESSION, &m_Dictionary);
231 }
232 
TestStream_ZLibGZip()233 void zlibStream::TestStream_ZLibGZip()
234 {
235     // Only use default compression level, as this test is
236     // for testing if the streams can determine the stream type info them self...
237     doTestStreamData(wxZLIB_AUTO, wxZLIB_ZLIB, wxZ_DEFAULT_COMPRESSION);
238     doTestStreamData(wxZLIB_AUTO, wxZLIB_GZIP, wxZ_DEFAULT_COMPRESSION);
239 }
240 
Decompress_BadData()241 void zlibStream::Decompress_BadData()
242 {
243     // Setup the bad data stream and the zlib stream.
244     wxMemoryInputStream memstream_in(GetDataBuffer(), DATABUFFER_SIZE);
245     CPPUNIT_ASSERT(memstream_in.IsOk());
246     wxZlibInputStream zstream_in(memstream_in);
247     CPPUNIT_ASSERT(zstream_in.IsOk()); // We did not yet read from the stream
248                                        // so it should still be OK.
249     // Try to force the stream to go to bad status.
250     CPPUNIT_ASSERT(!zstream_in.Eof());
251     if (zstream_in.IsOk())
252         zstream_in.GetC();
253 
254     // Because of the bad data in the input stream the zlib
255     // stream should be marked as NOT OK.
256     CPPUNIT_ASSERT(!zstream_in.IsOk());
257 }
258 
Decompress_wx251_zlib114_Data_NoHeader()259 void zlibStream::Decompress_wx251_zlib114_Data_NoHeader()
260 {
261     const unsigned char data[] = {171,202,201,76,82,72,73,44,73,84,72,46,74,77,44,73,77,81,40,207,44,201,80,40,175,8,207,76,73,79,45,41,86,48,210,51,213,171,80,136,246,77,44,74,206,80,48,50,143,213,1,202,69,249,120,58,197,251,249,199,123,184,58,186,184,6,233,40,84,129,12,49,212,51,212,51,1,0,32};
262     const char *value = "zlib data created with wxWidgets 2.5.x [March 27], wxZLIB_NO_HEADER, zlib 1.1.4";
263     const size_t data_size = sizeof(data);
264     const size_t value_size = strlen(value);
265     // We need to specify wxZLIB_NO_HEADER because wxZLIB_AUTO can't find it his self.
266     doDecompress_ExternalData(data, value, data_size, value_size, wxZLIB_NO_HEADER);
267 }
268 
Decompress_wx251_zlib114_Data_ZLib()269 void zlibStream::Decompress_wx251_zlib114_Data_ZLib()
270 {
271     const unsigned char data[] = {120,156,171,202,201,76,82,72,73,44,73,84,72,46,74,77,44,73,77,81,40,207,44,201,80,40,175,8,207,76,73,79,45,41,86,48,210,51,213,171,80,136,246,77,44,74,206,80,48,50,143,213,1,202,69,249,120,58,197,131,8,29,133,42,144,126,67,61,67,61,19,0,191,86,23,216};
272     const char *value = "zlib data created with wxWidgets 2.5.x [March 27], wxZLIB_ZLIB, zlib 1.1.4";
273     const size_t data_size = sizeof(data);
274     const size_t value_size = strlen(value);
275     doDecompress_ExternalData(data, value, data_size, value_size);
276 }
277 
Decompress_gzip135Data()278 void zlibStream::Decompress_gzip135Data()
279 {
280     // Compressed data was on the command line with gzip 1.3.5.
281     const unsigned char gzip135_data[] = {31,139,8,0,177,248,112,64,4,3,115,206,207,45,40,74,45,46,78,77,81,72,73,44,73,84,72,46,74,77,44,1,114,202,51,75,50,20,220,253,66,21,210,171,50,11,20,12,245,140,245,76,185,0,1,107,16,80,44,0,0,0,0};
282     const char *gzip135_value = "Compressed data created with GNU gzip 1.3.5\n";
283     // Size of the value and date items.
284     const size_t data_size = sizeof(gzip135_data);
285     const size_t value_size = strlen(gzip135_value);
286 
287     // Perform a generic data test on the data.
288     doDecompress_ExternalData(gzip135_data, gzip135_value, data_size, value_size);
289 }
290 
GetDataBuffer()291 const char *zlibStream::GetDataBuffer()
292 {
293     return m_DataBuffer;
294 }
295 
GetCompressedData()296 const unsigned char *zlibStream::GetCompressedData()
297 {
298     if (!m_pCompressedData)
299     {
300         // Construct the compressed data live.
301         wxMemoryOutputStream memstream_out;
302         {
303             const char *buf = "01234567890123456789012345678901234567890123456789"; /* = 50 */
304             wxZlibOutputStream zstream_out(memstream_out);
305             zstream_out.Write(buf, strlen(buf));
306         }
307 
308         // Copy the to the
309         m_SizeCompressedData = memstream_out.GetSize();
310         m_pCompressedData = new unsigned char[m_SizeCompressedData];
311         memstream_out.CopyTo(m_pCompressedData, m_SizeCompressedData);
312     }
313 
314     CPPUNIT_ASSERT(m_pCompressedData != NULL);
315     return m_pCompressedData;
316 }
317 
doTestStreamData(int input_flag,int output_flag,int compress_level,const wxMemoryBuffer * buf)318 void zlibStream::doTestStreamData(int input_flag, int output_flag, int compress_level, const wxMemoryBuffer *buf)
319 {
320     size_t fail_pos;
321     char last_value = 0;
322     bool bWasEOF;
323 
324     {   // Part one: Create a compressed file.
325         wxFileOutputStream fstream_out(FILENAME_GZ);
326         CPPUNIT_ASSERT(fstream_out.IsOk());
327         {
328             wxZlibOutputStream zstream_out(fstream_out, compress_level, output_flag);
329             CPPUNIT_ASSERT_MESSAGE("Could not create the output stream", zstream_out.IsOk());
330 
331             if (buf)
332                 zstream_out.SetDictionary(*buf);
333 
334             // Next: Compress some data so the file is containing something.
335             zstream_out.Write(GetDataBuffer(), DATABUFFER_SIZE);
336         }
337 
338         // Next thing is required by zlib versions pre 1.2.0.
339         if (input_flag == wxZLIB_NO_HEADER)
340             fstream_out.PutC(' ');
341     }
342 
343     {   // Part two: Verify that the compressed data when uncompressed
344         //           matches the original data.
345         wxFileInputStream fstream_in(FILENAME_GZ);
346         CPPUNIT_ASSERT(fstream_in.IsOk());
347         wxZlibInputStream zstream_in(fstream_in, input_flag);
348         CPPUNIT_ASSERT_MESSAGE("Could not create the input stream", zstream_in.IsOk());
349 
350         if (buf)
351             zstream_in.SetDictionary(*buf);
352 
353         // Next: Check char per char if the returned data is valid.
354         const char *pbuf = GetDataBuffer();
355         for (fail_pos = 0; !zstream_in.Eof(); fail_pos++)
356         {
357             last_value = zstream_in.GetC();
358             if (zstream_in.LastRead() != 1 ||
359                 last_value != pbuf[fail_pos])
360                 break;
361         }
362 
363         bWasEOF = zstream_in.Eof();
364     }
365 
366     // Remove the temp file...
367     ::wxRemoveFile(FILENAME_GZ);
368 
369     // Check state of the verify action.
370     if (fail_pos != DATABUFFER_SIZE || !bWasEOF)
371     {
372         wxString msg;
373         msg << wxT("Wrong data item at pos ") << fail_pos
374             << wxT(" (Org_val ") << GetDataBuffer()[fail_pos]
375             << wxT(" != Zlib_val ") << last_value
376             << wxT("), with compression level ") << compress_level;
377         CPPUNIT_FAIL(string(msg.mb_str()));
378     }
379 }
380 
doDecompress_ExternalData(const unsigned char * data,const char * value,size_t data_size,size_t value_size,int flag)381 void zlibStream::doDecompress_ExternalData(const unsigned char *data, const char *value, size_t data_size, size_t value_size, int flag)
382 {
383     // See that the input is ok.
384     wxASSERT(data != NULL);
385     wxASSERT(value != NULL);
386     wxASSERT(data_size > 0);
387     wxASSERT(value_size > 0);
388 
389     // Quickly try to see if the data is valid.
390     switch (flag)
391     {
392     case wxZLIB_NO_HEADER:
393         break;
394     case wxZLIB_ZLIB:
395         if (!(data_size >= 1 && data[0] == 0x78))
396         {
397             wxLogError(wxT("zlib data seems to not be zlib data!"));
398         }
399         break;
400     case wxZLIB_GZIP:
401         if (!(data_size >= 2 && data[0] == 0x1F && data[1] == 0x8B))
402         {
403             wxLogError(wxT("gzip data seems to not be gzip data!"));
404         }
405         break;
406     case wxZLIB_AUTO:
407         if (!(data_size >= 1 && data[0] == 0x78) ||
408             !(data_size >= 2 && data[0] == 0x1F && data[1] == 0x8B))
409         {
410             wxLogError(wxT("Data seems to not be zlib or gzip data!"));
411         }
412         break;
413     default:
414         wxLogError(wxT("Unknown flag, skipping quick test."));
415     };
416 
417     // Creat the needed streams.
418     wxMemoryInputStream memstream_in(data, data_size);
419     CPPUNIT_ASSERT(memstream_in.IsOk());
420     wxZlibInputStream zstream_in(memstream_in, flag);
421     CPPUNIT_ASSERT(zstream_in.IsOk());
422 
423     bool bValueEq = true;
424     size_t i;
425     for (i = 0; !zstream_in.Eof(); i++)
426     {
427         char last_value = zstream_in.GetC();
428 
429         // First check if it is a valid read.
430         if (zstream_in.LastRead() == 1)
431         {
432             // Check the values
433             if (last_value != value[i])
434             {
435                 bValueEq = false;
436                 break;
437             }
438         }
439         else
440         {
441             // If the read failed and turned the stream to Eof we stop reading.
442             if (zstream_in.Eof())
443                 break;
444 
445             CPPUNIT_ASSERT_MESSAGE("Stream is no longer ok!", zstream_in.IsOk());
446         }
447 
448         // Don't go over the end of the value buffer...
449         if (i == value_size)
450         {
451             // And if we do then try to see how long the stream actually is.
452             while (!zstream_in.Eof())
453             {
454                 // Move one item along in the stream.
455                 (void)zstream_in.GetC();
456                 i++;
457 
458                 // Check if we are in an infinite loop by multiplying value_size
459                 // by 5 to have a *much* bigger range then the real range.
460                 // Note: In case you ask yourself, why 5, the answer is no reason...
461                 //       it is not too big and not to small a size, nothing more
462                 //       nothing less to it.
463                 if (i > (value_size*5))
464                 {
465                     // Note: Please make sure Input_Eof test passed.
466                     CPPUNIT_FAIL("Infinite stream detected, breaking the infinite loop");
467                     return;
468                 }
469             }
470         }
471     }
472 
473     CPPUNIT_ASSERT_EQUAL( i, value_size );
474     CPPUNIT_ASSERT( bValueEq );
475 }
476 
DoCreateInStream()477 wxZlibInputStream *zlibStream::DoCreateInStream()
478 {
479     const unsigned char *buf = GetCompressedData();
480     m_pTmpMemInStream = new wxMemoryInputStream(buf, m_SizeCompressedData);
481     CPPUNIT_ASSERT(m_pTmpMemInStream->IsOk());
482     wxZlibInputStream *pzstream_in = new wxZlibInputStream(*m_pTmpMemInStream);
483     CPPUNIT_ASSERT(pzstream_in->IsOk());
484     return pzstream_in;
485 }
DoCreateOutStream()486 wxZlibOutputStream *zlibStream::DoCreateOutStream()
487 {
488     m_pTmpMemOutStream = new wxMemoryOutputStream();
489     CPPUNIT_ASSERT(m_pTmpMemOutStream->IsOk());
490     wxZlibOutputStream *pzstream_out = new wxZlibOutputStream(*m_pTmpMemOutStream);
491     CPPUNIT_ASSERT(pzstream_out->IsOk());
492     return pzstream_out;
493 }
DoDeleteInStream()494 void zlibStream::DoDeleteInStream()
495 {
496     delete m_pTmpMemInStream;
497     m_pTmpMemInStream = NULL;
498 }
DoDeleteOutStream()499 void zlibStream::DoDeleteOutStream()
500 {
501     delete m_pTmpMemOutStream;
502     m_pTmpMemOutStream = NULL;
503 }
504 
505 
genExtTestData(wxTextOutputStream & out,const char * buf,int flag)506 void zlibStream::genExtTestData(wxTextOutputStream &out, const char *buf, int flag)
507 {
508     unsigned char *data;
509     size_t size;
510 
511     {   // Gen data
512         wxMemoryOutputStream memstream_out;
513         {
514             wxZlibOutputStream zstream_out(memstream_out, wxZ_DEFAULT_COMPRESSION, flag);
515             zstream_out.Write(buf, strlen(buf));
516         }
517         if (flag == wxZLIB_NO_HEADER)
518             memstream_out.PutC(' ');
519 
520         size = memstream_out.GetSize();
521         data = new unsigned char[size];
522         memstream_out.CopyTo(data, size);
523     }
524 
525     out << wxT("void zlibStream::Decompress_wxXXXData()") << wxT("\n");
526     out << wxT("{") << wxT("\n") << wxT("    const unsigned char data[] = {");
527 
528     size_t i;
529     for (i = 0; i < size; i++)
530     {
531         if (i+1 != size)
532             out << wxString::Format(wxT("%d,"), data[i]);
533         else
534             out << wxString::Format(wxT("%d"), data[i]);
535     }
536     delete [] data;
537 
538     out << wxT("};") << wxT("\n");
539     out << wxT("    const char *value = \"") << wxString(buf, wxConvUTF8) << wxT("\";") << wxT("\n");
540     out << wxT("    const size_t data_size = sizeof(data);") << wxT("\n");
541     out << wxT("    const size_t value_size = strlen(value);") << wxT("\n");
542     out << wxT("    doDecompress_ExternalData(data, value, data_size, value_size);") << wxT("\n");
543     out << wxT("}") << wxT("\n");
544 }
545 
546 
547 // Register the stream sub suite, by using some stream helper macro.
548 // Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
549 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(zlibStream)
550 
551