/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "strescape.h"
struct strinput {
const char *input;
const char *output;
};
static struct {
const char *input;
const char *const *output;
} strsplit_tests[] = {
{ /*tabescaped_input3*/NULL, (const char *const []) {
"",
} },
{ "", (const char *const []) { NULL } },
{ tabescaped_input, (const char *const []) {
} },
};
static void test_str_escape(void)
{
{ "foo", "foo" },
{ "\\\\\\\\\\\"\\\"\\\'\\\'", "\\\\\"\"\'\'" },
{ "\\a\\n\\r\\", "anr" }
};
{ "foo", "foo" },
{ "\001", "\0011" },
{ "\t", "\001t" },
{ "\r", "\001r" },
{ "\n", "\001n" },
{ "\001\001\t\t\r\r\n\n", "\0011\0011\001t\001t\001r\001r\001n\001n" }
};
unsigned int i;
test_begin("str_escape");
for (i = 1; i < sizeof(buf); i++)
buf[i-1] = i;
"\\\\\\\\\\\"\\\"\\\'\\\'") == 0);
test_end();
test_begin("str_unescape");
for (i = 0; i < N_ELEMENTS(unesc); i++) {
str_truncate(str, 0);
}
test_end();
test_begin("str_unescape_next");
escaped = "foo\"bar\\\"b\\\\az\"plop";
escaped = "foo\\";
test_end();
test_begin("str_tabescape");
for (i = 0; i < N_ELEMENTS(tabesc); i++) {
str_truncate(str, 0);
}
str_truncate(str, 0);
tabstr = "\0012\001l\001";
test_end();
}
static void test_tabescape(void)
{
test_begin("string tabescaping");
/* unescaping */
str_truncate(str, 0);
/* unescaping with wrongly written tabescape-input */
str_truncate(str, 0);
test_assert(strcmp(str_tabunescape(t_strdup_noconst(wrong_tabescaped_input)), wrong_tabescaped_output) == 0);
test_end();
}
static void test_strsplit_tabescaped(void)
{
const char *const *args;
test_begin("*_strsplit_tabescaped()");
for (unsigned int i = 0; i < N_ELEMENTS(strsplit_tests); i++) {
}
test_end();
}
static void test_strsplit_tabescaped_inplace(void)
{
const char *const *args;
test_begin("*_strsplit_tabescaped_inplace()");
for (unsigned int i = 0; i < N_ELEMENTS(strsplit_tests); i++) {
}
test_end();
}
void test_strescape(void)
{
}