Browse Source

Base64/32 tests for #229.

pull/230/head
EinMByte 9 years ago
parent
commit
7d38b1a9b9
  1. 28
      tests/Data.cpp

28
tests/Data.cpp

@ -47,6 +47,20 @@ BOOST_AUTO_TEST_CASE(Base64Decode) @@ -47,6 +47,20 @@ BOOST_AUTO_TEST_CASE(Base64Decode)
BOOST_CHECK_EQUAL(size, 25);
}
BOOST_AUTO_TEST_CASE(Base64EncodeBufferTooSmall)
{
const uint8_t input[] = {0x53, 0xd3};
char result[3];
BOOST_CHECK_EQUAL(ByteStreamToBase64(input, 2, result, 3), 0);
}
BOOST_AUTO_TEST_CASE(Base64DecodeBufferTooSmall)
{
const char* input = "U9M=";
uint8_t result[1];
BOOST_CHECK_EQUAL(Base64ToByteStream(input, 4, result, 1), 0);
}
BOOST_AUTO_TEST_CASE(Base32EncodeEmpty)
{
BOOST_CHECK_EQUAL(ByteStreamToBase32(nullptr, 0, nullptr, 0), 0);
@ -86,4 +100,18 @@ BOOST_AUTO_TEST_CASE(Base32Decode) @@ -86,4 +100,18 @@ BOOST_AUTO_TEST_CASE(Base32Decode)
BOOST_CHECK_EQUAL(size, 25);
}
BOOST_AUTO_TEST_CASE(Base32EncodeBufferTooSmall)
{
const uint8_t input[] = {0x53, 0xd3};
char result[3];
BOOST_CHECK_EQUAL(ByteStreamToBase64(input, 2, result, 3), 0);
}
BOOST_AUTO_TEST_CASE(Base32DecodeBufferTooSmall)
{
const char* input = "kpjq";
uint8_t result[1];
BOOST_CHECK_EQUAL(Base64ToByteStream(input, 4, result, 1), 0);
}
BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save