You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base64_tests.cpp 884B

12345678910111213141516171819202122232425
  1. // Copyright (c) 2011-2013 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #include "utilstrencodings.h"
  5. #include "test/test_bitcoin.h"
  6. #include <boost/test/unit_test.hpp>
  7. BOOST_FIXTURE_TEST_SUITE(base64_tests, BasicTestingSetup)
  8. BOOST_AUTO_TEST_CASE(base64_testvectors)
  9. {
  10. static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
  11. static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
  12. for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
  13. {
  14. std::string strEnc = EncodeBase64(vstrIn[i]);
  15. BOOST_CHECK(strEnc == vstrOut[i]);
  16. std::string strDec = DecodeBase64(strEnc);
  17. BOOST_CHECK(strDec == vstrIn[i]);
  18. }
  19. }
  20. BOOST_AUTO_TEST_SUITE_END()