test-lib.c revision 90b50df264b57e0f63cd8cc6aea1ce3bb7cf5f64
/* Copyright (c) 2007 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "array.h"
#include "str.h"
#include "base64.h"
#include "bsearch-insert-pos.h"
#include "seq-range-array.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;
bool success;
for (i = 0; i < N_ELEMENTS(input); i++) {
str_truncate(str, 0);
}
}
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, -1 },
{ "foo barits", 0, -1 },
{ "just niin", 1, -1 },
{ "hel", 1, 4 },
{ "hel", -1, 4 },
{ "hel", -1, 4 }
};
unsigned int i;
int ret;
bool success;
for (i = 0; i < N_ELEMENTS(input); i++) {
str_truncate(str, 0);
src_pos = 0;
}
}
{
}
static void test_bsearch_insert_pos(void)
{
static const unsigned int input[] = {
1, 5, 9, 15, 16, -1,
1, 5, 9, 15, 16, 17, -1,
-1
};
static const unsigned int max_key = 18;
const unsigned int *cur;
bool success;
for (i = 0; cur[0] != -1U; i++) {
else if (idx == 0)
else {
}
if (!success)
break;
}
success);
}
}
static void test_seq_range_array(void)
{
static const unsigned int input[] = {
1, 2, 3, 4, 5, -1U,
2, 3, 4, -1U,
1, 2, 4, 5, -1U,
1, 3, 5, -1U,
1, -1U,
5, -1U,
-1U
};
bool old_exists, success;
start = i;
for (; input[i] != -1U; i++) {
for (j = start; j < i; j++) {
}
}
break;
}
}
success);
array_free(&range);
}
}
int main(void)
{
test_init();
return test_deinit();
}