dovecot-2.0: Renamed test-istream.c to test-istream-crlf.c

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 14 02:04:01 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/bba7c46359ac
changeset: 9785:bba7c46359ac
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 13 19:03:52 2009 -0400
description:
Renamed test-istream.c to test-istream-crlf.c

diffstat:

5 files changed, 103 insertions(+), 108 deletions(-)
src/lib/Makefile.am         |    2 
src/lib/test-istream-crlf.c |  100 ++++++++++++++++++++++++++++++++++++++++
src/lib/test-istream.c      |  105 -------------------------------------------
src/lib/test-lib.c          |    2 
src/lib/test-lib.h          |    2 

diffs (249 lines):

diff -r 3296870a8510 -r bba7c46359ac src/lib/Makefile.am
--- a/src/lib/Makefile.am	Thu Aug 13 18:33:18 2009 -0400
+++ b/src/lib/Makefile.am	Thu Aug 13 19:03:52 2009 -0400
@@ -219,7 +219,7 @@ test_lib_SOURCES = \
 	test-bsearch-insert-pos.c \
 	test-buffer.c \
 	test-hex-binary.c \
-	test-istream.c \
+	test-istream-crlf.c \
 	test-mempool-alloconly.c \
 	test-network.c \
 	test-primes.c \
diff -r 3296870a8510 -r bba7c46359ac src/lib/test-istream-crlf.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/test-istream-crlf.c	Thu Aug 13 19:03:52 2009 -0400
@@ -0,0 +1,100 @@
+/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
+
+#include "test-lib.h"
+#include "str.h"
+#include "istream-internal.h"
+#include "istream-crlf.h"
+
+static void test_istream_crlf_input(const char *input, unsigned int num)
+{
+	string_t *output;
+	const unsigned char *data;
+	size_t size;
+	ssize_t ret;
+	unsigned int i, j, pos, input_len = strlen(input);
+	struct istream *istream, *crlf_istream;
+	bool success;
+
+	output = t_str_new(256);
+
+	for (j = 0; j < 4; j++) {
+		istream = i_stream_create_from_data(input, input_len);
+		success = TRUE;
+		str_truncate(output, 0);
+		if (j%2 == 0) {
+			/* drop CRs */
+			crlf_istream = i_stream_create_lf(istream);
+			for (i = 0; i < input_len; i++) {
+				if (input[i] == '\r' &&
+				    (i == input_len || input[i+1] == '\n'))
+					;
+				else
+					str_append_c(output, input[i]);
+			}
+		} else {
+			/* add missing CRs */
+			crlf_istream = i_stream_create_crlf(istream);
+			for (i = 0; i < input_len; i++) {
+				if (input[i] == '\n' &&
+				    (i == 0 || input[i-1] != '\r'))
+					str_append_c(output, '\r');
+				str_append_c(output, input[i]);
+			}
+		}
+
+		pos = 0;
+		for (i = 1; i <= input_len; i++) {
+			if (j >= 2) {
+				i_stream_unref(&istream);
+				i_stream_unref(&crlf_istream);
+				istream = i_stream_create_from_data(input,
+								    input_len);
+				crlf_istream = j%2 == 0 ?
+					i_stream_create_lf(istream) :
+					i_stream_create_crlf(istream);
+				pos = 0;
+			}
+			istream->real_stream->pos = i;
+			if (crlf_istream->real_stream->buffer_size != 0) {
+				/* this is pretty evil */
+				crlf_istream->real_stream->buffer_size =
+					I_MAX(crlf_istream->real_stream->pos, i);
+			}
+			ret = i_stream_read(crlf_istream);
+			data = i_stream_get_data(crlf_istream, &size);
+			if (ret > 0) {
+				if (pos + (unsigned int)ret != size) {
+					success = FALSE;
+					break;
+				}
+				pos += ret;
+			}
+			if (memcmp(data, str_data(output), size) != 0) {
+				success = FALSE;
+				break;
+			}
+		}
+		if (size != str_len(output))
+			success = FALSE;
+		i_stream_unref(&crlf_istream);
+		i_stream_unref(&istream);
+
+		test_out(t_strdup_printf("test_istream_crlf(%d)", num*4+j),
+			 success);
+	}
+}
+
+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;
+
+	for (i = 0; i < N_ELEMENTS(input); i++)
+		test_istream_crlf_input(input[i], i);
+}
diff -r 3296870a8510 -r bba7c46359ac src/lib/test-istream.c
--- a/src/lib/test-istream.c	Thu Aug 13 18:33:18 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
-
-#include "test-lib.h"
-#include "str.h"
-#include "istream-internal.h"
-#include "istream-crlf.h"
-
-static void test_istream_crlf_input(const char *input, unsigned int num)
-{
-	string_t *output;
-	const unsigned char *data;
-	size_t size;
-	ssize_t ret;
-	unsigned int i, j, pos, input_len = strlen(input);
-	struct istream *istream, *crlf_istream;
-	bool success;
-
-	output = t_str_new(256);
-
-	for (j = 0; j < 4; j++) {
-		istream = i_stream_create_from_data(input, input_len);
-		success = TRUE;
-		str_truncate(output, 0);
-		if (j%2 == 0) {
-			/* drop CRs */
-			crlf_istream = i_stream_create_lf(istream);
-			for (i = 0; i < input_len; i++) {
-				if (input[i] == '\r' &&
-				    (i == input_len || input[i+1] == '\n'))
-					;
-				else
-					str_append_c(output, input[i]);
-			}
-		} else {
-			/* add missing CRs */
-			crlf_istream = i_stream_create_crlf(istream);
-			for (i = 0; i < input_len; i++) {
-				if (input[i] == '\n' &&
-				    (i == 0 || input[i-1] != '\r'))
-					str_append_c(output, '\r');
-				str_append_c(output, input[i]);
-			}
-		}
-
-		pos = 0;
-		for (i = 1; i <= input_len; i++) {
-			if (j >= 2) {
-				i_stream_unref(&istream);
-				i_stream_unref(&crlf_istream);
-				istream = i_stream_create_from_data(input,
-								    input_len);
-				crlf_istream = j%2 == 0 ?
-					i_stream_create_lf(istream) :
-					i_stream_create_crlf(istream);
-				pos = 0;
-			}
-			istream->real_stream->pos = i;
-			if (crlf_istream->real_stream->buffer_size != 0) {
-				/* this is pretty evil */
-				crlf_istream->real_stream->buffer_size =
-					I_MAX(crlf_istream->real_stream->pos, i);
-			}
-			ret = i_stream_read(crlf_istream);
-			data = i_stream_get_data(crlf_istream, &size);
-			if (ret > 0) {
-				if (pos + (unsigned int)ret != size) {
-					success = FALSE;
-					break;
-				}
-				pos += ret;
-			}
-			if (memcmp(data, str_data(output), size) != 0) {
-				success = FALSE;
-				break;
-			}
-		}
-		if (size != str_len(output))
-			success = FALSE;
-		i_stream_unref(&crlf_istream);
-		i_stream_unref(&istream);
-
-		test_out(t_strdup_printf("test_istream_crlf(%d)", num*4+j),
-			 success);
-	}
-}
-
-static 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;
-
-	for (i = 0; i < N_ELEMENTS(input); i++)
-		test_istream_crlf_input(input[i], i);
-}
-
-void test_istream(void)
-{
-	test_istream_crlf();
-}
diff -r 3296870a8510 -r bba7c46359ac src/lib/test-lib.c
--- a/src/lib/test-lib.c	Thu Aug 13 18:33:18 2009 -0400
+++ b/src/lib/test-lib.c	Thu Aug 13 19:03:52 2009 -0400
@@ -11,7 +11,7 @@ int main(void)
 		test_bsearch_insert_pos,
 		test_buffer,
 		test_hex_binary,
-		test_istream,
+		test_istream_crlf,
 		test_mempool_alloconly,
 		test_network,
 		test_primes,
diff -r 3296870a8510 -r bba7c46359ac src/lib/test-lib.h
--- a/src/lib/test-lib.h	Thu Aug 13 18:33:18 2009 -0400
+++ b/src/lib/test-lib.h	Thu Aug 13 19:03:52 2009 -0400
@@ -10,7 +10,7 @@ void test_bsearch_insert_pos(void);
 void test_bsearch_insert_pos(void);
 void test_buffer(void);
 void test_hex_binary(void);
-void test_istream(void);
+void test_istream_crlf(void);
 void test_mempool_alloconly(void);
 void test_network(void);
 void test_primes(void);


More information about the dovecot-cvs mailing list