annotate src/zlib-1.2.7/contrib/iostream3/test.cc @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
parents e13257ea84a4
children
rev   line source
Chris@4 1 /*
Chris@4 2 * Test program for gzifstream and gzofstream
Chris@4 3 *
Chris@4 4 * by Ludwig Schwardt <schwardt@sun.ac.za>
Chris@4 5 * original version by Kevin Ruland <kevin@rodin.wustl.edu>
Chris@4 6 */
Chris@4 7
Chris@4 8 #include "zfstream.h"
Chris@4 9 #include <iostream> // for cout
Chris@4 10
Chris@4 11 int main() {
Chris@4 12
Chris@4 13 gzofstream outf;
Chris@4 14 gzifstream inf;
Chris@4 15 char buf[80];
Chris@4 16
Chris@4 17 outf.open("test1.txt.gz");
Chris@4 18 outf << "The quick brown fox sidestepped the lazy canine\n"
Chris@4 19 << 1.3 << "\nPlan " << 9 << std::endl;
Chris@4 20 outf.close();
Chris@4 21 std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n"
Chris@4 22 << "The quick brown fox sidestepped the lazy canine\n"
Chris@4 23 << 1.3 << "\nPlan " << 9 << std::endl;
Chris@4 24
Chris@4 25 std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n";
Chris@4 26 inf.open("test1.txt.gz");
Chris@4 27 while (inf.getline(buf,80,'\n')) {
Chris@4 28 std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
Chris@4 29 }
Chris@4 30 inf.close();
Chris@4 31
Chris@4 32 outf.rdbuf()->pubsetbuf(0,0);
Chris@4 33 outf.open("test2.txt.gz");
Chris@4 34 outf << setcompression(Z_NO_COMPRESSION)
Chris@4 35 << "The quick brown fox sidestepped the lazy canine\n"
Chris@4 36 << 1.3 << "\nPlan " << 9 << std::endl;
Chris@4 37 outf.close();
Chris@4 38 std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form";
Chris@4 39
Chris@4 40 std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n";
Chris@4 41 inf.rdbuf()->pubsetbuf(0,0);
Chris@4 42 inf.open("test2.txt.gz");
Chris@4 43 while (inf.getline(buf,80,'\n')) {
Chris@4 44 std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
Chris@4 45 }
Chris@4 46 inf.close();
Chris@4 47
Chris@4 48 return 0;
Chris@4 49
Chris@4 50 }