aboutsummaryrefslogtreecommitdiff
path: root/t/t0081-line-buffer.sh
blob: 68d616399548effd6285d26278eee29aa33f245d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

test_description="Test the svn importer's input handling routines.
"
. ./test-lib.sh

test_expect_success 'read greeting' '
	echo HELLO >expect &&
	test-line-buffer <<-\EOF >actual &&
	read 6
	HELLO
	EOF
	test_cmp expect actual
'

test_expect_success '0-length read, send along greeting' '
	echo HELLO >expect &&
	test-line-buffer <<-\EOF >actual &&
	read 0
	copy 6
	HELLO
	EOF
	test_cmp expect actual
'

test_expect_success 'buffer_read_string copes with null byte' '
	>expect &&
	q_to_nul <<-\EOF | test-line-buffer >actual &&
	read 2
	Q
	EOF
	test_cmp expect actual
'

test_expect_success 'skip, copy null byte' '
	echo Q | q_to_nul >expect &&
	q_to_nul <<-\EOF | test-line-buffer >actual &&
	skip 2
	Q
	copy 2
	Q
	EOF
	test_cmp expect actual
'

test_expect_success 'long reads are truncated' '
	echo foo >expect &&
	test-line-buffer <<-\EOF >actual &&
	read 5
	foo
	EOF
	test_cmp expect actual
'

test_expect_success 'long copies are truncated' '
	printf "%s\n" "" foo >expect &&
	test-line-buffer <<-\EOF >actual &&
	read 1

	copy 5
	foo
	EOF
	test_cmp expect actual
'

test_done