/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "str-sanitize.h"
struct str_sanitize_test {
const char *str;
unsigned int max_len;
};
void test_str_sanitize(void)
{
{ "abc", 2, "..." },
{ "abcd", 3, "..." },
{ "abcde", 4, "a..." },
{ "\xD1\x81", 1, "..." },
{ "\xD1\x81", 2, "\xD1\x81" },
{ "\xC3\xA4\xC3\xA4zyxa", 1, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 2, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 3, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 4, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 5, "\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 6, "\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 7, "\xC3\xA4\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 8, "\xC3\xA4\xC3\xA4zyxa" },
{ "\001x\x1fy\x81", 10, "?x?y?" }
};
const char *str;
unsigned int i;
test_begin("str_sanitize");
for (i = 0; i < N_ELEMENTS(tests); i++) {
else
}
test_end();
test_begin("str_sanitize_append");
for (i = 0; i < N_ELEMENTS(tests); i++) {
continue;
str_truncate(str2, 0);
else
}
test_end();
}