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 5
11 HELLO
12 EOF
13 test_cmp expect actual
14 '
16 test_expect_success '0-length read, send along greeting' '
17 printf "%s\n" "" HELLO >expect &&
18 test-line-buffer <<-\EOF >actual &&
19 read 0
21 copy 5
22 HELLO
23 EOF
24 test_cmp expect actual
25 '
27 test_expect_success 'buffer_read_string copes with trailing null byte' '
28 echo >expect &&
29 q_to_nul <<-\EOF | test-line-buffer >actual &&
30 read 1
31 Q
32 EOF
33 test_cmp expect actual
34 '
36 test_expect_success '0-length read, copy null byte' '
37 printf "%s\n" "" Q | q_to_nul >expect &&
38 q_to_nul <<-\EOF | test-line-buffer >actual &&
39 read 0
41 copy 1
42 Q
43 EOF
44 test_cmp expect actual
45 '
47 test_expect_success 'long reads are truncated' '
48 printf "%s\n" foo "" >expect &&
49 test-line-buffer <<-\EOF >actual &&
50 read 5
51 foo
52 EOF
53 test_cmp expect actual
54 '
56 test_expect_success 'long copies are truncated' '
57 printf "%s\n" "" foo >expect &&
58 test-line-buffer <<-\EOF >actual &&
59 read 0
61 copy 5
62 foo
63 EOF
64 test_cmp expect actual
65 '
67 test_done