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