Commit 59c4d3c3 authored by Niels Möller's avatar Niels Möller
Browse files

(test_main): Test BASE64_ENCODE_LENGTH

and BASE64_DECODE_LENGTH. Updated test of base64_encode_raw (used
to be base64_encode).

Rev: src/nettle/testsuite/base64-test.c:1.3
parent 434b2682
......@@ -4,6 +4,21 @@
int
test_main(void)
{
ASSERT(BASE64_ENCODE_LENGTH(0) == 0); /* At most 4 bits */
ASSERT(BASE64_ENCODE_LENGTH(1) == 2); /* At most 12 bits */
ASSERT(BASE64_ENCODE_LENGTH(2) == 3); /* At most 20 bits */
ASSERT(BASE64_ENCODE_LENGTH(3) == 4); /* At most 28 bits */
ASSERT(BASE64_ENCODE_LENGTH(4) == 6); /* At most 36 bits */
ASSERT(BASE64_ENCODE_LENGTH(5) == 7); /* At most 44 bits */
ASSERT(BASE64_ENCODE_LENGTH(12) == 16); /* At most 100 bits */
ASSERT(BASE64_ENCODE_LENGTH(13) == 18); /* At most 108 bits */
ASSERT(BASE64_DECODE_LENGTH(0) == 0); /* At most 6 bits */
ASSERT(BASE64_DECODE_LENGTH(1) == 1); /* At most 12 bits */
ASSERT(BASE64_DECODE_LENGTH(2) == 2); /* At most 18 bits */
ASSERT(BASE64_DECODE_LENGTH(3) == 3); /* At most 24 bits */
ASSERT(BASE64_DECODE_LENGTH(4) == 3); /* At most 30 bits */
test_armor(&nettle_base64, 0, "", "");
test_armor(&nettle_base64, 1, "H", "SA==");
test_armor(&nettle_base64, 2, "He", "SGU=");
......@@ -16,10 +31,10 @@ test_main(void)
{
/* Test overlapping areas */
uint8_t buffer[] = "Helloxxxx";
struct base64_ctx ctx;
struct base64_decode_ctx ctx;
ASSERT(BASE64_ENCODE_LENGTH(5) == 8);
ASSERT(8 == base64_encode(buffer, 5, buffer));
ASSERT(BASE64_ENCODE_RAW_LENGTH(5) == 8);
base64_encode_raw(buffer, 5, buffer);
ASSERT(MEMEQ(9, buffer, "SGVsbG8=x"));
buffer[6] = '=';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment