diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-07-30 17:05:47 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-07-30 17:05:47 +0000 |
commit | 3f0f30442de297859cccc18f28db83b4e755d36f (patch) | |
tree | 6e9fdd9ff6febcdd87779f7663fecc0388e0dd73 /src/tests | |
parent | 8551cdd3bbf66d8b7b0fea8aa1e0fbddd86bca47 (diff) | |
download | libbu++-3f0f30442de297859cccc18f28db83b4e755d36f.tar.gz libbu++-3f0f30442de297859cccc18f28db83b4e755d36f.tar.bz2 libbu++-3f0f30442de297859cccc18f28db83b4e755d36f.tar.xz libbu++-3f0f30442de297859cccc18f28db83b4e755d36f.zip |
Bu::Buffer actually works, and works really well. I dig it. Bu::BZip2 now
follows the new filter guidelines, where read and write report the amount of
data consumed, not the amount processed. I.e. when writing, it reports how
much of your incoming data it used, not how many bytes it wrote on the other
end.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/buffer.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/buffer.cpp b/src/tests/buffer.cpp new file mode 100644 index 0000000..a1a1105 --- /dev/null +++ b/src/tests/buffer.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "bu/membuf.h" | ||
2 | #include "bu/buffer.h" | ||
3 | #include "bu/file.h" | ||
4 | |||
5 | using namespace Bu; | ||
6 | |||
7 | int main( int argc, char *argv[] ) | ||
8 | { | ||
9 | argc--,argv++; | ||
10 | if( argc == 0 ) | ||
11 | { | ||
12 | MemBuf mOut; | ||
13 | Buffer bOut( mOut, 10 ); | ||
14 | |||
15 | for( int j = 0; j < 4; j++ ) | ||
16 | bOut.write("hi ", 3 ); | ||
17 | |||
18 | printf("Preflush: \"%s\"\n", mOut.getString().getStr() ); | ||
19 | bOut.flush(); | ||
20 | |||
21 | printf("Final: \"%s\"\n", mOut.getString().getStr() ); | ||
22 | } | ||
23 | else | ||
24 | { | ||
25 | File fIn( *argv, File::Read ); | ||
26 | Buffer bIn( fIn, 10 ); | ||
27 | |||
28 | char buf[5]; | ||
29 | for( int j = 0; j < 5; j++ ) | ||
30 | { | ||
31 | buf[bIn.read( buf, 4 )] = '\0'; | ||
32 | printf("Four chars: \"%s\"\n", buf ); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | return 0; | ||
37 | } | ||
38 | |||