#include <gtest/gtest.h>
#include <set>
+#include <cctype>
-#include <boost/foreach.hpp>
#include <boost/assign.hpp>
#include <common/base64.h>
#include <common/except.h>
namespace {
- static const char DICTIONARY[] =
- {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- '/', '+'
- };
-
const std::set<char>& get_dictionary()
{
- static const std::set<char> dictionary(
- DICTIONARY, DICTIONARY + sizeof(DICTIONARY));
+ static const std::set<char> dictionary{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '/', '+'
+ };
return dictionary;
}
TEST(Base64Test, InvalidInputLength)
{
// 0 and 4 characters should be ok
- /*EXPECT_THROW(from_base64("1"), caspar_exception);
+ EXPECT_THROW(from_base64("1"), caspar_exception);
EXPECT_THROW(from_base64("12"), caspar_exception);
EXPECT_THROW(from_base64("123"), caspar_exception);
EXPECT_THROW(from_base64("1234\n567"), caspar_exception);
- EXPECT_THROW(from_base64("12345"), caspar_exception);*/
+ EXPECT_THROW(from_base64("12345"), caspar_exception);
}
TEST(Base64Test, InvalidInputCharacters)
{
auto invalid = PREFIX + static_cast<char>(i);
- //EXPECT_THROW(from_base64(invalid), std::exception);
+ EXPECT_THROW(from_base64(invalid), std::exception);
}
}
}