From ac5fb6be210b63fd7216541679f513dc97491ede Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 31 Jul 2009 17:53:02 +0000 Subject: Wow, Bu::Base64 had a bug about premature end of stream / not base64 data, now it throws exceptions. It'll still try to process bad data for a while though. Also, it turns out that Bu::File never reported EOS, now it does, appropriately. I'm about to change Bu::Stream::isEOS to be Bu::Stream::isEos, this is your warning. --- src/tests/base64.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'src/tests/base64.cpp') diff --git a/src/tests/base64.cpp b/src/tests/base64.cpp index 3122d5c..5e36448 100644 --- a/src/tests/base64.cpp +++ b/src/tests/base64.cpp @@ -1,4 +1,5 @@ #include "bu/file.h" +#include "bu/membuf.h" #include "bu/base64.h" int main( int argc, char *argv[] ) @@ -31,12 +32,42 @@ int main( int argc, char *argv[] ) Bu::File fOut( argv[1], Bu::File::WriteNew ); Bu::Base64 bIn( fIn ); - char buf[16]; + char buf[1024]; for(;;) { - int iRead = bIn.read( buf, 16 ); + int iRead = bIn.read( buf, 1024 ); + printf("Read %d bytes.\n", iRead ); fOut.write( buf, iRead ); - if( iRead < 16 ) + if( iRead == 0 ) + break; + } + } + else if( argv[0][0] == 'D' ) + { + argv++; + Bu::MemBuf mIn; + { + Bu::File fIn( argv[0], Bu::File::Read ); + char buf[1024]; + for(;;) + { + int iRead = fIn.read( buf, 1024 ); + mIn.write( buf, iRead ); + if( iRead < 1024 ) + break; + } + mIn.setPos( 0 ); + } + Bu::File fOut( argv[1], Bu::File::WriteNew ); + Bu::Base64 bIn( mIn ); + + char buf[1024]; + for(;;) + { + int iRead = bIn.read( buf, 1024 ); + printf("Read %d bytes.\n", iRead ); + fOut.write( buf, iRead ); + if( iRead == 0 ) break; } } -- cgit v1.2.3