1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-03-12 15:31:03 +00:00

Base64/32 tests for #229.

This commit is contained in:
EinMByte 2015-07-24 15:32:47 +02:00
parent c612d21639
commit 7d38b1a9b9

View File

@ -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)
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()