PIVX Core  5.6.99
P2P Digital Currency
base64_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "utilstrencodings.h"
6 #include "test/test_pivx.h"
7 
8 #include <boost/test/unit_test.hpp>
9 
11 
12 BOOST_AUTO_TEST_CASE(base64_testvectors)
13 {
14  static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
15  static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
16  for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
17  {
18  std::string strEnc = EncodeBase64(vstrIn[i]);
19  BOOST_CHECK(strEnc == vstrOut[i]);
20  std::string strDec = DecodeBase64(strEnc);
21  BOOST_CHECK(strDec == vstrIn[i]);
22  }
23 }
24 
BOOST_AUTO_TEST_CASE(base64_testvectors)
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK(expr)
Definition: object.cpp:17
Basic testing setup.
Definition: test_pivx.h:51
std::string EncodeBase64(Span< const unsigned char > input)
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)