/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "test-common.h"
#include "md5.h"
#include "message-header-hash.h"
static const char test_input_with_nuls[] = {
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
"\x20!?x??yz\x7f\x80\x90\xff-plop\xff"
};
static const struct {
const char *input;
unsigned int version;
const char *output;
} tests[] = {
{ "???hi???", 1, "???hi???" },
{ "?hi?", 2, "?hi?" },
{ "\x01hi\x01", 2, "?hi?" },
{ "???hi???", 2, "?hi?" },
{ "\x01?hi??\x01", 2, "?hi?" },
{ "?\t?hi?\t?", 2, "?\t?hi?\t?" },
{ "\n\nhi\n\n", 2, "\n\nhi\n\n" },
{ "", 2, "" },
{ " ", 2, " " },
{ " ", 2, " " },
{ "? ? ? hi \x01\x02 \x03 ", 2, "? ? ? hi ? ? " },
{ "\n\nhi\n\n", 3, "\n\nhi\n\n" },
{ "", 3, "" },
{ " ", 3, "" },
{ " ", 3, "" },
{ " ? ", 3, "?" },
{ "? ? ? hi \x01\x02 \x03 ", 3, "???hi??" },
{ " \t \t", 3, "\t\t" },
{ "\n\nhi\n\n", 4, "\n\nhi\n\n" },
{ "", 4, "" },
{ " ", 4, "" },
{ " \t \t", 4, "" },
{ "foo\t\t", 4, "foo" },
};
static void test_message_header_hash_more(void)
{
test_begin("message_header_hash_more");
for (unsigned int i = 0; i < N_ELEMENTS(tests); i++) {
/* single byte at a time */
for (unsigned int j = 0; j < input_len; j++) {
&chr, 1);
}
/* random number of chars at a time */
for (unsigned int j = 0; j < input_len; ) {
const unsigned char *input_part =
input_part, len);
j += len;
}
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}