aboutsummaryrefslogtreecommitdiff
path: root/src/tests/base64.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-07-31 17:53:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-07-31 17:53:02 +0000
commitac5fb6be210b63fd7216541679f513dc97491ede (patch)
treeacbc8a91933f9e200d51f9a58f4f7b05173611ab /src/tests/base64.cpp
parent6070f3cb3fe44f17114fd58792055e9c91bd3576 (diff)
downloadlibbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.gz
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.bz2
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.xz
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.zip
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.
Diffstat (limited to 'src/tests/base64.cpp')
-rw-r--r--src/tests/base64.cpp37
1 files changed, 34 insertions, 3 deletions
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 @@
1#include "bu/file.h" 1#include "bu/file.h"
2#include "bu/membuf.h"
2#include "bu/base64.h" 3#include "bu/base64.h"
3 4
4int main( int argc, char *argv[] ) 5int main( int argc, char *argv[] )
@@ -31,12 +32,42 @@ int main( int argc, char *argv[] )
31 Bu::File fOut( argv[1], Bu::File::WriteNew ); 32 Bu::File fOut( argv[1], Bu::File::WriteNew );
32 Bu::Base64 bIn( fIn ); 33 Bu::Base64 bIn( fIn );
33 34
34 char buf[16]; 35 char buf[1024];
35 for(;;) 36 for(;;)
36 { 37 {
37 int iRead = bIn.read( buf, 16 ); 38 int iRead = bIn.read( buf, 1024 );
39 printf("Read %d bytes.\n", iRead );
38 fOut.write( buf, iRead ); 40 fOut.write( buf, iRead );
39 if( iRead < 16 ) 41 if( iRead == 0 )
42 break;
43 }
44 }
45 else if( argv[0][0] == 'D' )
46 {
47 argv++;
48 Bu::MemBuf mIn;
49 {
50 Bu::File fIn( argv[0], Bu::File::Read );
51 char buf[1024];
52 for(;;)
53 {
54 int iRead = fIn.read( buf, 1024 );
55 mIn.write( buf, iRead );
56 if( iRead < 1024 )
57 break;
58 }
59 mIn.setPos( 0 );
60 }
61 Bu::File fOut( argv[1], Bu::File::WriteNew );
62 Bu::Base64 bIn( mIn );
63
64 char buf[1024];
65 for(;;)
66 {
67 int iRead = bIn.read( buf, 1024 );
68 printf("Read %d bytes.\n", iRead );
69 fOut.write( buf, iRead );
70 if( iRead == 0 )
40 break; 71 break;
41 } 72 }
42 } 73 }