blob: abc540cbd2f5bd2bdccabb387f4feb5838932f77 [file] [log] [blame]
Ed Tanous54640292025-03-17 20:55:20 -07001#include <libcper/base64.h>
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <assert.h>
6#include <string.h>
7
8void test_base64_encode_good()
9{
10 int32_t encoded_len = 0;
11 const char *data = "f";
12 char *encoded = base64_encode((unsigned char *)data, strlen(data),
13 &encoded_len);
14 assert(encoded_len == 4);
15 assert(memcmp(encoded, "Zg==", encoded_len) == 0);
16 free(encoded);
17}
18
19void test_base64_decode_good()
20{
21 int32_t decoded_len = 0;
22 const char *data = "Zg==";
23 UINT8 *decoded = base64_decode(data, strlen(data), &decoded_len);
24 assert(decoded_len == 1);
25 assert(decoded[0] == 'f');
26 free(decoded);
27}