Merge branch 'tr/doc-git-cherry'
[git.git] / t / t0081-line-buffer.sh
blobbd83ed371acb5075b2b3cbb7866d36aa4bd48519
1 #!/bin/sh
3 test_description="Test the svn importer's input handling routines.
5 These tests provide some simple checks that the line_buffer API
6 behaves as advertised.
8 While at it, check that input of newlines and null bytes are handled
9 correctly.
11 . ./test-lib.sh
13 test_expect_success 'hello world' '
14 echo ">HELLO" >expect &&
15 test-line-buffer <<-\EOF >actual &&
16 binary 6
17 HELLO
18 EOF
19 test_cmp expect actual
22 test_expect_success '0-length read, send along greeting' '
23 echo ">HELLO" >expect &&
24 test-line-buffer <<-\EOF >actual &&
25 binary 0
26 copy 6
27 HELLO
28 EOF
29 test_cmp expect actual
32 test_expect_success 'read from file descriptor' '
33 rm -f input &&
34 echo hello >expect &&
35 echo hello >input &&
36 echo copy 6 |
37 test-line-buffer "&4" 4<input >actual &&
38 test_cmp expect actual
41 test_expect_success 'skip, copy null byte' '
42 echo Q | q_to_nul >expect &&
43 q_to_nul <<-\EOF | test-line-buffer >actual &&
44 skip 2
46 copy 2
48 EOF
49 test_cmp expect actual
52 test_expect_success 'read null byte' '
53 echo ">QhelloQ" | q_to_nul >expect &&
54 q_to_nul <<-\EOF | test-line-buffer >actual &&
55 binary 8
56 QhelloQ
57 EOF
58 test_cmp expect actual
61 test_expect_success 'long reads are truncated' '
62 echo ">foo" >expect &&
63 test-line-buffer <<-\EOF >actual &&
64 binary 5
65 foo
66 EOF
67 test_cmp expect actual
70 test_expect_success 'long copies are truncated' '
71 printf "%s\n" ">" foo >expect &&
72 test-line-buffer <<-\EOF >actual &&
73 binary 1
75 copy 5
76 foo
77 EOF
78 test_cmp expect actual
81 test_expect_success 'long binary reads are truncated' '
82 echo ">foo" >expect &&
83 test-line-buffer <<-\EOF >actual &&
84 binary 5
85 foo
86 EOF
87 test_cmp expect actual
90 test_done