aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/base64.cpp2
-rw-r--r--src/unit/base64.unit28
2 files changed, 30 insertions, 0 deletions
diff --git a/src/base64.cpp b/src/base64.cpp
index 18a18e5..04ca009 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -118,6 +118,8 @@ Bu::size Bu::Base64::read( void *pBuf, Bu::size nBytes )
118 { 118 {
119 if( rNext.isEos() ) 119 if( rNext.isEos() )
120 { 120 {
121 if( iRPos == 0 )
122 iRPos = iChars;
121 bEosIn = true; 123 bEosIn = true;
122 if( j != 0 ) 124 if( j != 0 )
123 { 125 {
diff --git a/src/unit/base64.unit b/src/unit/base64.unit
new file mode 100644
index 0000000..e4630c5
--- /dev/null
+++ b/src/unit/base64.unit
@@ -0,0 +1,28 @@
1// vim: syntax=cpp
2/*
3 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
4 *
5 * This file is part of the libbu++ library and is released under the
6 * terms of the license contained in the file LICENSE.
7 */
8
9#include "bu/strfilter.h"
10#include "bu/base64.h"
11
12suite MemBuf
13{
14 test decode01
15 {
16 unitTest( Bu::decodeStr<Bu::Base64>("RnVu") == "Fun" );
17 unitTest( Bu::decodeStr<Bu::Base64>("V2hhdA==") == "What" );
18 unitTest( Bu::decodeStr<Bu::Base64>("SGVsbG8=") == "Hello" );
19 }
20
21 test encode01
22 {
23 unitTest( Bu::decodeStr<Bu::Base64>("R n V u") == "Fun" );
24 unitTest( Bu::decodeStr<Bu::Base64>("V2\n\n\thh dA==") == "What" );
25 unitTest( Bu::decodeStr<Bu::Base64>("\n\n\t\t SGV\r\ns\tbG8\n=") == "Hello" );
26 }
27}
28