[PATCH 6/8] tests: give vcs-svn/line_buffer its own test script

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Nieder
Date: Sunday, January 2, 2011 - 5:51 pm

Split the line_buffer test into small pieces and move it to its
own file as preparation for adding more tests.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t0080-vcs-svn.sh     |   54 --------------------------------------
 t/t0081-line-buffer.sh |   67 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 54 deletions(-)
 create mode 100755 t/t0081-line-buffer.sh

diff --git a/t/t0080-vcs-svn.sh b/t/t0080-vcs-svn.sh
index 8be9700..99a314b 100755
--- a/t/t0080-vcs-svn.sh
+++ b/t/t0080-vcs-svn.sh
@@ -76,60 +76,6 @@ test_expect_success 'obj pool: high-water mark' '
 	test_cmp expected actual
 '
 
-test_expect_success 'line buffer' '
-	echo HELLO >expected1 &&
-	printf "%s\n" "" HELLO >expected2 &&
-	echo >expected3 &&
-	printf "%s\n" "" Q | q_to_nul >expected4 &&
-	printf "%s\n" foo "" >expected5 &&
-	printf "%s\n" "" foo >expected6 &&
-
-	test-line-buffer <<-\EOF >actual1 &&
-	read 5
-	HELLO
-	EOF
-
-	test-line-buffer <<-\EOF >actual2 &&
-	read 0
-
-	copy 5
-	HELLO
-	EOF
-
-	q_to_nul <<-\EOF |
-	read 1
-	Q
-	EOF
-	test-line-buffer >actual3 &&
-
-	q_to_nul <<-\EOF |
-	read 0
-
-	copy 1
-	Q
-	EOF
-	test-line-buffer >actual4 &&
-
-	test-line-buffer <<-\EOF >actual5 &&
-	read 5
-	foo
-	EOF
-
-	test-line-buffer <<-\EOF >actual6 &&
-	read 0
-
-	copy 5
-	foo
-	EOF
-
-	test_cmp expected1 actual1 &&
-	test_cmp expected2 actual2 &&
-	test_cmp expected3 actual3 &&
-	test_cmp expected4 actual4 &&
-	test_cmp expected5 actual5 &&
-	test_cmp expected6 actual6
-'
-
 test_expect_success 'string pool' '
 	echo a does not equal b >expected.differ &&
 	echo a equals a >expected.match &&
diff --git a/t/t0081-line-buffer.sh b/t/t0081-line-buffer.sh
new file mode 100755
index 0000000..13ac735
--- /dev/null
+++ b/t/t0081-line-buffer.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+test_description="Test the svn importer's input handling routines.
+"
+. ./test-lib.sh
+
+test_expect_success 'read greeting' '
+	echo HELLO >expect &&
+	test-line-buffer <<-\EOF >actual &&
+	read 5
+	HELLO
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success '0-length read, send along greeting' '
+	printf "%s\n" "" HELLO >expect &&
+	test-line-buffer <<-\EOF >actual &&
+	read 0
+
+	copy 5
+	HELLO
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success 'buffer_read_string copes with trailing null byte' '
+	echo >expect &&
+	q_to_nul <<-\EOF | test-line-buffer >actual &&
+	read 1
+	Q
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success '0-length read, copy null byte' '
+	printf "%s\n" "" Q | q_to_nul >expect &&
+	q_to_nul <<-\EOF | test-line-buffer >actual &&
+	read 0
+
+	copy 1
+	Q
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success 'long reads are truncated' '
+	printf "%s\n" foo "" >expect &&
+	test-line-buffer <<-\EOF >actual &&
+	read 5
+	foo
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success 'long copies are truncated' '
+	printf "%s\n" "" foo >expect &&
+	test-line-buffer <<-\EOF >actual &&
+	read 0
+
+	copy 5
+	foo
+	EOF
+	test_cmp expect actual
+'
+
+test_done
-- 
1.7.4.rc0.580.g89dc.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/4] vcs-svn: eliminate global byte_buffer, Jonathan Nieder, (Fri Dec 24, 1:08 am)
[PATCH 3/4] vcs-svn: collect line_buffer data in a struct, Jonathan Nieder, (Fri Dec 24, 1:18 am)
[PATCH 6/8] tests: give vcs-svn/line_buffer its own test s ..., Jonathan Nieder, (Sun Jan 2, 5:51 pm)
[PATCH 8/8] t0081 (line-buffer): add buffering tests, Jonathan Nieder, (Sun Jan 2, 6:07 pm)
Re: [PATCH 8/8] t0081 (line-buffer): add buffering tests, Jonathan Nieder, (Sun Jan 2, 6:34 pm)
[PATCH 09/12] vcs-svn: add binary-safe read function, Jonathan Nieder, (Sun Jan 2, 8:05 pm)
[PATCH 10/12] vcs-svn: allow character-oriented input, Jonathan Nieder, (Sun Jan 2, 8:06 pm)
[PATCH 11/12] vcs-svn: allow input from file descriptor, Jonathan Nieder, (Sun Jan 2, 8:09 pm)