summaryrefslogtreecommitdiff
path: root/t/t0080-vcs-svn.sh
diff options
context:
space:
mode:
authorDavid Barr <david.barr@cordelta.com>2010-08-09 22:39:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-15 02:35:37 (GMT)
commit3bbaec00a8ffc6ea7e71c3b707851fe663d93a45 (patch)
tree5af41401b9e6764754058d4305a0d212190828b9 /t/t0080-vcs-svn.sh
parent1d73b52f5ba4184de6acf474f14668001304a10c (diff)
downloadgit-3bbaec00a8ffc6ea7e71c3b707851fe663d93a45.zip
git-3bbaec00a8ffc6ea7e71c3b707851fe663d93a45.tar.gz
git-3bbaec00a8ffc6ea7e71c3b707851fe663d93a45.tar.bz2
Add stream helper library
This library provides thread-unsafe fgets()- and fread()-like functions where the caller does not have to supply a buffer. It maintains a couple of static buffers and provides an API to use them. [rr: allow input from files other than stdin] [jn: with tests, documentation, and error handling improvements] Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0080-vcs-svn.sh')
-rwxr-xr-xt/t0080-vcs-svn.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/t/t0080-vcs-svn.sh b/t/t0080-vcs-svn.sh
index 99a314b..d3225ad 100755
--- a/t/t0080-vcs-svn.sh
+++ b/t/t0080-vcs-svn.sh
@@ -76,6 +76,60 @@ 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 &&
+ 5
+ HELLO
+ EOF
+
+ test-line-buffer <<-\EOF >actual2 &&
+ 0
+
+ 5
+ HELLO
+ EOF
+
+ q_to_nul <<-\EOF |
+ 1
+ Q
+ EOF
+ test-line-buffer >actual3 &&
+
+ q_to_nul <<-\EOF |
+ 0
+
+ 1
+ Q
+ EOF
+ test-line-buffer >actual4 &&
+
+ test-line-buffer <<-\EOF >actual5 &&
+ 5
+ foo
+ EOF
+
+ test-line-buffer <<-\EOF >actual6 &&
+ 0
+
+ 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 &&