annotate src/zlib-1.2.7/contrib/iostream3/test.cc @ 89:8a15ff55d9af

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