xref: /netbsd-src/common/dist/zlib/contrib/iostream2/zstream_test.cpp (revision aaf4ece63a859a04e37cf3a7229b5fab0157cc06)
1*aaf4ece6Schristos #include "zstream.h"
2*aaf4ece6Schristos #include <math.h>
3*aaf4ece6Schristos #include <stdlib.h>
4*aaf4ece6Schristos #include <iomanip.h>
5*aaf4ece6Schristos 
main()6*aaf4ece6Schristos void main() {
7*aaf4ece6Schristos     char h[256] = "Hello";
8*aaf4ece6Schristos     char* g = "Goodbye";
9*aaf4ece6Schristos     ozstream out("temp.gz");
10*aaf4ece6Schristos     out < "This works well" < h < g;
11*aaf4ece6Schristos     out.close();
12*aaf4ece6Schristos 
13*aaf4ece6Schristos     izstream in("temp.gz"); // read it back
14*aaf4ece6Schristos     char *x = read_string(in), *y = new char[256], z[256];
15*aaf4ece6Schristos     in > y > z;
16*aaf4ece6Schristos     in.close();
17*aaf4ece6Schristos     cout << x << endl << y << endl << z << endl;
18*aaf4ece6Schristos 
19*aaf4ece6Schristos     out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results
20*aaf4ece6Schristos     out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl;
21*aaf4ece6Schristos     out << z << endl << y << endl << x << endl;
22*aaf4ece6Schristos     out << 1.1234567890123456789 << endl;
23*aaf4ece6Schristos 
24*aaf4ece6Schristos     delete[] x; delete[] y;
25*aaf4ece6Schristos }
26