test-base64.c revision 814bf67459ad405a157af0b8940602024d7fadfe
/* Copyright (c) 2007-2015 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "base64.h"
static void test_base64_encode(void)
{
static const char *input[] = {
"hello world",
"foo barits",
"just niin"
};
static const char *output[] = {
"aGVsbG8gd29ybGQ=",
"Zm9vIGJhcml0cw==",
"anVzdCBuaWlu"
};
unsigned int i;
test_begin("base64_encode()");
for (i = 0; i < N_ELEMENTS(input); i++) {
str_truncate(str, 0);
}
test_end();
}
struct test_base64_decode_output {
const char *text;
int ret;
unsigned int src_pos;
};
static void test_base64_decode(void)
{
static const char *input[] = {
"\taGVsbG8gd29ybGQ=",
"\nZm9v\n \tIGJh \t\ncml0cw==",
" anVzdCBuaWlu \n",
"aGVsb",
"aGVsb!!!!!",
"aGVs!!!!!"
};
static const struct test_base64_decode_output output[] = {
{ "hello world", 0, UINT_MAX },
{ "foo barits", 0, UINT_MAX },
{ "hel", 1, 4 },
{ "hel", -1, 4 },
{ "hel", -1, 4 }
};
unsigned int i;
int ret;
test_begin("base64_decode()");
for (i = 0; i < N_ELEMENTS(input); i++) {
str_truncate(str, 0);
src_pos = 0;
}
test_end();
}
static void test_base64_random(void)
{
char buf[10];
unsigned int i, j, max;
test_begin("base64 encode/decode with random input");
for (i = 0; i < 1000; i++) {
for (j = 0; j < max; j++)
str_truncate(str, 0);
str_truncate(dest, 0);
}
test_end();
}
void test_base64(void)
{
}