diff --git a/include/engine/base64.hpp b/include/engine/base64.hpp index 811ef9308..30fcb5b78 100644 --- a/include/engine/base64.hpp +++ b/include/engine/base64.hpp @@ -14,6 +14,9 @@ #include #include +// RFC 4648 "The Base16, Base32, and Base64 Data Encodings" +// See: https://tools.ietf.org/html/rfc4648 + namespace osrm { namespace engine diff --git a/unit_tests/engine/base64.cpp b/unit_tests/engine/base64.cpp index 16749dc3f..63af7acc2 100644 --- a/unit_tests/engine/base64.cpp +++ b/unit_tests/engine/base64.cpp @@ -3,8 +3,23 @@ #include #include +// RFC 4648 "The Base16, Base32, and Base64 Data Encodings" BOOST_AUTO_TEST_SUITE(base64) +// For test vectors see section 10: https://tools.ietf.org/html/rfc4648#section-10 +BOOST_AUTO_TEST_CASE(rfc4648_test_vectors) +{ + using namespace osrm::engine; + + BOOST_CHECK_EQUAL(encodeBase64(""), ""); + BOOST_CHECK_EQUAL(encodeBase64("f"), "Zg=="); + BOOST_CHECK_EQUAL(encodeBase64("fo"), "Zm8="); + BOOST_CHECK_EQUAL(encodeBase64("foo"), "Zm9v"); + BOOST_CHECK_EQUAL(encodeBase64("foob"), "Zm9vYg=="); + BOOST_CHECK_EQUAL(encodeBase64("fooba"), "Zm9vYmE="); + BOOST_CHECK_EQUAL(encodeBase64("foobar"), "Zm9vYmFy"); +} + BOOST_AUTO_TEST_CASE(encoding) {} BOOST_AUTO_TEST_CASE(decoding) {}