Example #1
0
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_istream_crlf_input(input[i]);
	test_end();

#define ISTREAM_CRLF_TEST_REPS 1000
	test_begin("istream crlf(random)");
	for (i = 0; i < ISTREAM_CRLF_TEST_REPS; i++) T_BEGIN {
		char buf[100];
		size_t len = 0;
		while (len < sizeof(buf) - 1) {
			switch(rand()%16) {
			case 0: goto outahere;
			case 1: buf[len] = '\r'; break;
			case 2: buf[len] = '\n'; break;
			default: buf[len]= '.'; break;
			}
			len++;
		}
	outahere:
		buf[len] = '\0';
		if (len > 0)
			test_istream_crlf_input(buf);
	} T_END;
	test_end();
}
Example #2
0
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_istream_crlf_input(input[i]);
	test_end();
}