/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "hash-format.h"
struct hash_format_test {
const char *input;
const char *output;
};
void test_hash_format(void)
{
static const char *fail_input[] = {
"%",
"%A{sha1}",
"%{sha1",
"%{sha1:8",
"%{sha1:8a}",
"%{sha1:0}",
"%{sha1:168}",
};
{ "%{sha1}", "8843d7f92416211de9ebb963ff4ce28125932878" },
{ "*%{sha1}*", "*8843d7f92416211de9ebb963ff4ce28125932878*" },
{ "*%{sha1:8}*", "*88*" },
{ "%{sha1:152}", "8843d7f92416211de9ebb963ff4ce281259328" },
{ "%X{size}", "6" },
{ "%{sha256:80}", "c3ab8ff13720e8ad9047" },
{ "%{sha512:80}", "0a50261ebd1a390fed2b" },
{ "%{md4}", "547aefd231dcbaac398625718336f143" },
{ "%{md5}", "3858f62230ac3c915f300c664312c63f" },
{ "%{sha256:80}-%X{size}", "c3ab8ff13720e8ad9047-6" }
};
const char *error;
unsigned int i;
test_begin("hash_format");
for (i = 0; fail_input[i] != NULL; i++)
for (i = 0; i < N_ELEMENTS(tests); i++) {
str_truncate(str, 0);
}
test_end();
}