1 #!/bin/sh
3 test_description="Test the svn importer's input handling routines.
4 "
5 . ./test-lib.sh
7 test_expect_success 'read greeting' '
8 echo HELLO >expect &&
9 test-line-buffer <<-\EOF >actual &&
10 read 6
11 HELLO
12 EOF
13 test_cmp expect actual
14 '
16 test_expect_success '0-length read, send along greeting' '
17 echo HELLO >expect &&
18 test-line-buffer <<-\EOF >actual &&
19 read 0
20 copy 6
21 HELLO
22 EOF
23 test_cmp expect actual
24 '
26 test_expect_success 'buffer_read_string copes with null byte' '
27 >expect &&
28 q_to_nul <<-\EOF | test-line-buffer >actual &&
29 read 2
30 Q
31 EOF
32 test_cmp expect actual
33 '
35 test_expect_success 'skip, copy null byte' '
36 echo Q | q_to_nul >expect &&
37 q_to_nul <<-\EOF | test-line-buffer >actual &&
38 skip 2
39 Q
40 copy 2
41 Q
42 EOF
43 test_cmp expect actual
44 '
46 test_expect_success 'long reads are truncated' '
47 echo foo >expect &&
48 test-line-buffer <<-\EOF >actual &&
49 read 5
50 foo
51 EOF
52 test_cmp expect actual
53 '
55 test_expect_success 'long copies are truncated' '
56 printf "%s\n" "" foo >expect &&
57 test-line-buffer <<-\EOF >actual &&
58 read 1
60 copy 5
61 foo
62 EOF
63 test_cmp expect actual
64 '
66 test_done