From 7c9cf28012f65ce6a67651030b817d7d45eda62b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 25 Oct 2011 15:11:32 +0000 Subject: 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. --- src/unit/base64.unit | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/unit/base64.unit (limited to 'src/unit/base64.unit') 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 @@ +// vim: syntax=cpp +/* + * Copyright (C) 2007-2011 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/strfilter.h" +#include "bu/base64.h" + +suite MemBuf +{ + test decode01 + { + unitTest( Bu::decodeStr("RnVu") == "Fun" ); + unitTest( Bu::decodeStr("V2hhdA==") == "What" ); + unitTest( Bu::decodeStr("SGVsbG8=") == "Hello" ); + } + + test encode01 + { + unitTest( Bu::decodeStr("R n V u") == "Fun" ); + unitTest( Bu::decodeStr("V2\n\n\thh dA==") == "What" ); + unitTest( Bu::decodeStr("\n\n\t\t SGV\r\ns\tbG8\n=") == "Hello" ); + } +} + -- cgit v1.2.3