huangcm
2025-08-25 f350412dc55c15118d0a7925d1071877498e5e24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
 
[ -f testing.sh ] && . testing.sh
 
#testing "name" "command" "result" "infile" "stdin"
 
echo -n "foo " | gzip > f1.gz
echo "bar" | gzip > f2.gz
 
# zcat is basically just `gzip -dc`...
testing "files" "zcat f1.gz f2.gz && test -f f1.gz && test -f f2.gz" \
    "foo bar\n" "" ""
 
# zcat -c is allowed, but the -c changes nothing.
testing "-c" "zcat -c f1.gz f2.gz && test -f f1.gz && test -f f2.gz" \
    "foo bar\n" "" ""
 
# TODO: how to test "zcat -f"?
 
rm -f f1 f2 f1.gz f2.gz