2011-01-03 01:51:07 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description="Test the svn importer's input handling routines.
|
2011-01-03 02:07:16 +01:00
|
|
|
|
2011-03-30 10:11:41 +02:00
|
|
|
These tests provide some simple checks that the line_buffer API
|
|
|
|
behaves as advertised.
|
2011-01-03 02:07:16 +01:00
|
|
|
|
|
|
|
While at it, check that input of newlines and null bytes are handled
|
|
|
|
correctly.
|
2011-01-03 01:51:07 +01:00
|
|
|
"
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2011-01-03 02:07:16 +01:00
|
|
|
test_expect_success 'hello world' '
|
2011-03-25 05:09:19 +01:00
|
|
|
echo ">HELLO" >expect &&
|
2011-01-03 01:51:07 +01:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 05:09:19 +01:00
|
|
|
binary 6
|
2011-01-03 01:51:07 +01:00
|
|
|
HELLO
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '0-length read, send along greeting' '
|
2011-03-25 05:09:19 +01:00
|
|
|
echo ">HELLO" >expect &&
|
2011-01-03 01:51:07 +01:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 05:09:19 +01:00
|
|
|
binary 0
|
2011-01-03 01:52:28 +01:00
|
|
|
copy 6
|
2011-01-03 01:51:07 +01:00
|
|
|
HELLO
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 04:09:38 +01:00
|
|
|
test_expect_success 'read from file descriptor' '
|
|
|
|
rm -f input &&
|
|
|
|
echo hello >expect &&
|
|
|
|
echo hello >input &&
|
|
|
|
echo copy 6 |
|
|
|
|
test-line-buffer "&4" 4<input >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
2011-01-03 02:07:16 +01:00
|
|
|
|
2011-01-03 01:52:28 +01:00
|
|
|
test_expect_success 'skip, copy null byte' '
|
|
|
|
echo Q | q_to_nul >expect &&
|
2011-01-03 01:51:07 +01:00
|
|
|
q_to_nul <<-\EOF | test-line-buffer >actual &&
|
2011-01-03 01:52:28 +01:00
|
|
|
skip 2
|
|
|
|
Q
|
|
|
|
copy 2
|
2011-01-03 01:51:07 +01:00
|
|
|
Q
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 04:05:46 +01:00
|
|
|
test_expect_success 'read null byte' '
|
|
|
|
echo ">QhelloQ" | q_to_nul >expect &&
|
|
|
|
q_to_nul <<-\EOF | test-line-buffer >actual &&
|
|
|
|
binary 8
|
|
|
|
QhelloQ
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 01:51:07 +01:00
|
|
|
test_expect_success 'long reads are truncated' '
|
2011-03-25 05:09:19 +01:00
|
|
|
echo ">foo" >expect &&
|
2011-01-03 01:51:07 +01:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 05:09:19 +01:00
|
|
|
binary 5
|
2011-01-03 01:51:07 +01:00
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'long copies are truncated' '
|
2011-03-25 05:09:19 +01:00
|
|
|
printf "%s\n" ">" foo >expect &&
|
2011-01-03 01:51:07 +01:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 05:09:19 +01:00
|
|
|
binary 1
|
2011-01-03 01:51:07 +01:00
|
|
|
|
|
|
|
copy 5
|
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 04:05:46 +01:00
|
|
|
test_expect_success 'long binary reads are truncated' '
|
|
|
|
echo ">foo" >expect &&
|
|
|
|
test-line-buffer <<-\EOF >actual &&
|
|
|
|
binary 5
|
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 01:51:07 +01:00
|
|
|
test_done
|