/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "istream-private.h"
#include "istream-crlf.h"
{
const unsigned char *data;
for (j = 0; j < 4; j++) {
str_truncate(output, 0);
if (j%2 == 0) {
/* drop CRs */
for (i = 0; i < input_len; i++) {
if (input[i] == '\r' &&
;
else
}
} else {
/* add missing CRs */
for (i = 0; i < input_len; i++) {
if (input[i] == '\n' &&
}
}
pos = 0;
for (i = 1; i <= input_len; i++) {
if (j >= 2) {
crlf_istream = j%2 == 0 ?
pos = 0;
}
/* this is pretty evil */
}
}
if (size > 0)
size) == 0, j*10000+i);
}
}
}
void test_istream_crlf(void)
{
const char *input[] = {
"\rfoo",
"foo\nbar\r\nbaz\r\r\n",
"\r\nfoo",
"\r\r\n",
"\nfoo"
};
unsigned int i;
test_begin("istream crlf");
for (i = 0; i < N_ELEMENTS(input); i++)
test_end();
test_begin("istream crlf(random)");
for (i = 0; i < ISTREAM_CRLF_TEST_REPS; i++) T_BEGIN {
switch(i_rand()%16) {
case 0: goto outahere;
}
len++;
}
if (len > 0)
} T_END;
test_end();
}