aboutsummaryrefslogtreecommitdiff
path: root/src/unit
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-10-25 15:11:32 +0000
committerMike Buland <eichlan@xagasoft.com>2011-10-25 15:11:32 +0000
commit7c9cf28012f65ce6a67651030b817d7d45eda62b (patch)
tree0e03b7b4be8602053df7a7378b7972ff736a1bb9 /src/unit
parentb3adc199b6fbf3460d709934de5d92668d75a6cf (diff)
downloadlibbu++-7c9cf28012f65ce6a67651030b817d7d45eda62b.tar.gz
libbu++-7c9cf28012f65ce6a67651030b817d7d45eda62b.tar.bz2
libbu++-7c9cf28012f65ce6a67651030b817d7d45eda62b.tar.xz
libbu++-7c9cf28012f65ce6a67651030b817d7d45eda62b.zip
Fixed bug in base64 decoding. If an attempt is made to read data after the end
of the stream has been reached, and the input didn't end with '=' chars then it would return the final buffer an extra time before ending. Now it ends when it should, no matter how many extra times you try to read.
Diffstat (limited to 'src/unit')
-rw-r--r--src/unit/base64.unit28
1 files changed, 28 insertions, 0 deletions
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