From 3f0f30442de297859cccc18f28db83b4e755d36f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 30 Jul 2009 17:05:47 +0000 Subject: 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. --- src/tests/buffer.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/tests/buffer.cpp (limited to 'src/tests') 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 @@ +#include "bu/membuf.h" +#include "bu/buffer.h" +#include "bu/file.h" + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + argc--,argv++; + if( argc == 0 ) + { + MemBuf mOut; + Buffer bOut( mOut, 10 ); + + for( int j = 0; j < 4; j++ ) + bOut.write("hi ", 3 ); + + printf("Preflush: \"%s\"\n", mOut.getString().getStr() ); + bOut.flush(); + + printf("Final: \"%s\"\n", mOut.getString().getStr() ); + } + else + { + File fIn( *argv, File::Read ); + Buffer bIn( fIn, 10 ); + + char buf[5]; + for( int j = 0; j < 5; j++ ) + { + buf[bIn.read( buf, 4 )] = '\0'; + printf("Four chars: \"%s\"\n", buf ); + } + } + + return 0; +} + -- cgit v1.2.3