Skip to content
Snippets Groups Projects
Commit 6ed22096 authored by Niels Möller's avatar Niels Möller
Browse files

(test_main): Test encoding and decoding

in place.

Rev: src/nettle/testsuite/base64-test.c:1.2
parent cff9e510
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,22 @@ test_main(void) ...@@ -11,7 +11,22 @@ test_main(void)
test_armor(&nettle_base64, 4, "Hell", "SGVsbA=="); test_armor(&nettle_base64, 4, "Hell", "SGVsbA==");
test_armor(&nettle_base64, 5, "Hello", "SGVsbG8="); test_armor(&nettle_base64, 5, "Hello", "SGVsbG8=");
test_armor(&nettle_base64, 6, "Hello", "SGVsbG8A"); test_armor(&nettle_base64, 6, "Hello", "SGVsbG8A");
test_armor(&nettle_base64, 4, "\377\377\377\377", "/////w=="); test_armor(&nettle_base64, 4, "\xff\xff\xff\xff", "/////w==");
{
/* Test overlapping areas */
uint8_t buffer[] = "Helloxxxx";
struct base64_ctx ctx;
ASSERT(BASE64_ENCODE_LENGTH(5) == 8);
ASSERT(8 == base64_encode(buffer, 5, buffer));
ASSERT(MEMEQ(9, buffer, "SGVsbG8=x"));
buffer[6] = '=';
base64_decode_init(&ctx);
ASSERT(4 == base64_decode_update(&ctx, buffer, 8, buffer));
ASSERT(MEMEQ(9, buffer, "HellbG==x"));
}
SUCCESS(); SUCCESS();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment