]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0081-line-buffer.sh
hashmap: use *_entry APIs for iteration
[thirdparty/git.git] / t / t0081-line-buffer.sh
CommitLineData
232087fd
JN
1#!/bin/sh
2
3test_description="Test the svn importer's input handling routines.
d280f683 4
6908e999
JN
5These tests provide some simple checks that the line_buffer API
6behaves as advertised.
d280f683
JN
7
8While at it, check that input of newlines and null bytes are handled
9correctly.
232087fd
JN
10"
11. ./test-lib.sh
12
d280f683 13test_expect_success 'hello world' '
7e2fe3a9 14 echo ">HELLO" >expect &&
232087fd 15 test-line-buffer <<-\EOF >actual &&
7e2fe3a9 16 binary 6
232087fd
JN
17 HELLO
18 EOF
19 test_cmp expect actual
20'
21
22test_expect_success '0-length read, send along greeting' '
7e2fe3a9 23 echo ">HELLO" >expect &&
232087fd 24 test-line-buffer <<-\EOF >actual &&
7e2fe3a9 25 binary 0
7b990c90 26 copy 6
232087fd
JN
27 HELLO
28 EOF
29 test_cmp expect actual
30'
31
f57a8715 32test_expect_success !MINGW 'read from file descriptor' '
cb3f87cf
JN
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
39'
d280f683 40
7b990c90
JN
41test_expect_success 'skip, copy null byte' '
42 echo Q | q_to_nul >expect &&
232087fd 43 q_to_nul <<-\EOF | test-line-buffer >actual &&
7b990c90
JN
44 skip 2
45 Q
46 copy 2
232087fd
JN
47 Q
48 EOF
49 test_cmp expect actual
50'
51
e832f43c
JN
52test_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
59'
60
232087fd 61test_expect_success 'long reads are truncated' '
7e2fe3a9 62 echo ">foo" >expect &&
232087fd 63 test-line-buffer <<-\EOF >actual &&
7e2fe3a9 64 binary 5
232087fd
JN
65 foo
66 EOF
67 test_cmp expect actual
68'
69
70test_expect_success 'long copies are truncated' '
7e2fe3a9 71 printf "%s\n" ">" foo >expect &&
232087fd 72 test-line-buffer <<-\EOF >actual &&
7e2fe3a9 73 binary 1
232087fd
JN
74
75 copy 5
76 foo
77 EOF
78 test_cmp expect actual
79'
80
e832f43c
JN
81test_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
88'
89
232087fd 90test_done