summaryrefslogtreecommitdiff
path: root/t/t0081-line-buffer.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-01-03 00:51:07 (GMT)
committerJonathan Nieder <jrnieder@gmail.com>2011-02-26 10:57:59 (GMT)
commit232087fd99915abaa7d917fd181ad8477bb689f2 (patch)
tree49cc5a9f42f601b501ff6822ca2f5370cc28fd6a /t/t0081-line-buffer.sh
parent850c5ea44ce0b4aac3be7c4d14b38ec901e777d1 (diff)
downloadgit-232087fd99915abaa7d917fd181ad8477bb689f2.zip
git-232087fd99915abaa7d917fd181ad8477bb689f2.tar.gz
git-232087fd99915abaa7d917fd181ad8477bb689f2.tar.bz2
tests: give vcs-svn/line_buffer its own test script
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>
Diffstat (limited to 't/t0081-line-buffer.sh')
-rwxr-xr-xt/t0081-line-buffer.sh67
1 files changed, 67 insertions, 0 deletions
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