blob: f21e82c1226393717a3cfce04286566d03a43b0f (
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
|
#!/bin/sh
# Copyright 2026 by R M Yorston <rmy@pobox.com>
# Licensed under GPLv2, see file LICENSE in this source tree.
. ./testing.sh
# testing "description" "command" "result" "infile" "stdin"
testing "join common lines and unpaired from first file" \
"join -a 1 input -" \
"a 1 A\nb 2\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join common lines and unpaired from second file" \
"join -a 2 input -" \
"a 1 A\nc C\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join paired and unpaired lines from both files (union)" \
"join -a 1 -a 2 input -" \
"a 1 A\nb 2\nc C\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join unpaired lines from first file (difference)" \
"join -v 1 input -" \
"b 2\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join unpaired lines from second file (difference)" \
"join -v 2 input -" \
"c C\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join unpaired lines from both file (symmetric difference)" \
"join -v 1 -v 2 input -" \
"b 2\nc C\n" "a 1\nb 2\n" "a A\nc C\n"
testing "join duplicate keys give combinatorial results" "join input -" \
"a b c w x\na b c y z\na b c o p\na d e w x\na d e y z\na d e o p\n" \
"a b c\na d e\n" \
"a w x\na y z\na o p\n"
testing "join -o for fields to print, -e for empty fields" \
"join -a 1 -a 2 -e --- -o 0,1.2,2.2 input -" \
"a 123 abc\nb 456 ---\nc 789 def\nd --- ghi\n" \
"a 123\nb 456\nc 789\n" \
"a abc\nc def\nd ghi\n"
exit $FAILCOUNT
|