test-strescape.c revision 6ea49f0ffe92ac0d709ac9282e136a94df0053ee
/* Copyright (c) 2009-2016 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;
};
void test_strescape(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();
}