summaryrefslogtreecommitdiff
path: root/src/tests/streamstack.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
commit4b9289cfb260f4bcecaf23a810584ef6ef8e8501 (patch)
tree79136af08c7e42ba3322f0d73e9779e4354b318a /src/tests/streamstack.cpp
parentc7636dc954eddfe58f7959392602fbc9072d77e7 (diff)
downloadlibbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.gz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.bz2
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.xz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.zip
Ok, string stuff is working much, much better, a load of new unit tests have
been added, and I deleted a whole slew of stupid old tests that I don't need.
Diffstat (limited to 'src/tests/streamstack.cpp')
-rw-r--r--src/tests/streamstack.cpp100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/tests/streamstack.cpp b/src/tests/streamstack.cpp
deleted file mode 100644
index 4a0e128..0000000
--- a/src/tests/streamstack.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/streamstack.h"
9
10#include "bu/file.h"
11#include "bu/base64.h"
12#include "bu/bzip2.h"
13
14#include "bu/sio.h"
15
16#include <time.h>
17
18using namespace Bu;
19
20class DoStuff
21{
22public:
23 DoStuff( Bu::Stream &rStream ) :
24 rStream( rStream )
25 {
26 }
27
28 virtual ~DoStuff()
29 {
30 }
31
32 void write()
33 {
34 Bu::String s;
35 time_t tNow = time( NULL );
36 s = ctime( &tNow );
37 long lSize = s.getSize()-1;
38 rStream.write( &lSize, sizeof(long) );
39 rStream.write( s.getStr(), lSize );
40 }
41
42 void read()
43 {
44 Bu::String s;
45 long lSize;
46 rStream.read( &lSize, sizeof(long) );
47 s.setSize( lSize );
48 rStream.read( s.getStr(), lSize );
49 sio << "Read str(" << lSize << ") = '" << s << "'" << sio.nl;
50 }
51
52private:
53 Bu::Stream &rStream;
54};
55
56int main()
57{
58 Bu::StreamStack ss;
59
60 DoStuff ds( ss );
61
62 try
63 {
64 ds.write();
65 sio << "This shouldn't have worked." << sio.nl;
66 }
67 catch( Bu::ExceptionBase &e )
68 {
69 sio << "Got exception, this is good: " << e.what() << sio.nl;
70 }
71
72 ss.setStream( new Bu::File("Hello.test", Bu::File::WriteNew ) );
73
74 ds.write();
75
76 ss.pushFilter<Bu::Base64>();
77
78 ds.write();
79
80 ss.pushFilter<Bu::BZip2>();
81
82 ds.write();
83
84 ss.clear();
85
86 ss.setStream( new Bu::File("Hello.test", Bu::File::Read ) );
87
88 ds.read();
89
90 ss.pushFilter<Bu::Base64>();
91
92 ds.read();
93
94 ss.pushFilter<Bu::BZip2>();
95
96 ds.read();
97
98 return 0;
99}
100