/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "qp-decoder.h"
#include "test-common.h"
struct test_quoted_printable_decode_data {
const char *input;
const char *output;
int ret;
};
static void test_qp_decoder(void)
{
#define WHITESPACE70 WHITESPACE10 WHITESPACE10 WHITESPACE10 WHITESPACE10 WHITESPACE10 WHITESPACE10 WHITESPACE10
{ "foo \r\nbar=\n", "foo\r\nbar", 0, 0 },
{ "foo\t=\nbar", "foo\tbar", 0, 0 },
{ "foo = \n=01", "foo \001", 0, 0 },
{ "foo =\t\r\nbar", "foo bar", 0, 0 },
{ "foo =\r\n=01", "foo \001", 0, 0 },
{ "foo \nbar=\r\n", "foo\r\nbar", 0, 0 },
{ "=0A=0D ", "\n\r", 0, 0 },
{ "foo_bar", "foo_bar", 0, 0 },
{ "\n\n", "\r\n\r\n", 0, 0 },
{ "\r\n\n\n\r\n", "\r\n\r\n\r\n\r\n", 0, 0 },
{ "foo=", "foo=", 4, -1 },
{ "foo= \t", "foo= \t", 6, -1 },
{ "foo= \r", "foo= \r", 6, -1 },
{ "foo= \r bar", "foo= \r bar", 6, -1 },
{ "foo=A", "foo=A", 5, -1 },
{ "foo=Ax", "foo=Ax", 5, -1 },
{ "foo=Ax=xy", "foo=Ax=xy", 5, -1 },
/* above 76 whitespaces is invalid and gets truncated
(at 77th whitespace because of the current implementation) */
};
unsigned int i, j;
test_begin("qp-decoder");
for (i = 0; i < N_ELEMENTS(tests); i++) {
const char *error;
int ret;
/* try all at once */
ret = -1;
}
/* try in small pieces */
str_truncate(str, 0);
ret = 0;
for (j = 0; input[j] != '\0'; j++) {
unsigned char c = input[j];
ret = -1;
}
ret = -1;
str_truncate(str, 0);
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}