~sircmpwn/ctools

ref: cc69324393fda9bcbc73d30d1bda022263f012a8 ctools/test/cat -rwxr-xr-x 941 bytes
cc693243 — Gabor Koszegi Correct tee SIGINT test 1 year, 11 months ago
                                                                                
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
#!/bin/sh
tool="cat"
. "$HARNESS"

echo "this is a test file" >"$TMPDIR"/test-file-1
echo "this is another test file" >"$TMPDIR"/test-file-2

should_handle_one_file() (
	ct="$(cat "$TMPDIR"/test-file-1)"
	[ "$ct" = "this is a test file" ]
)

should_handle_two_files() (
	ct="$(cat "$TMPDIR"/test-file-1 "$TMPDIR"/test-file-2)"
	ref=$(echo "this is a test file" && echo "this is another test file")
	[ "$ct" = "$ref" ]
)

should_handle_stdin() (
	ct="$(echo "this is from stdin" | cat -)"
	[ "$ct" = "this is from stdin" ] || return 1
	ct="$(echo "this is from stdin" | cat)"
	[ "$ct" = "this is from stdin" ]
)

should_handle_u_flag() (
	# actual behavior is not especially important/testable
	ct="$(echo "this is from stdin" | cat -u)"
	[ "$ct" = "this is from stdin" ]
)

should_handle_ddash cat /dev/null

runtests \
	should_handle_ddash \
	should_handle_one_file \
	should_handle_two_files \
	should_handle_stdin \
	should_handle_u_flag