blob: e356865b4875b5b17ce669a25df79fea15a36f7a (
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
|
#!/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"
testing "join -o works for combinatorial" \
"join -o 0,1.2,2.2 input -" \
"a 123 abc\na 123 def\na 456 abc\na 456 def\n" \
"a 123\na 456\n" \
"a abc\na def\n"
testing "join -t works" \
"join -t A input -" \
"item 1A123Aabc\nitem 2A456Adef\n" \
"item 1A123\nitem 2A456\n" \
"item 1Aabc\nitem 2Adef\n"
exit $FAILCOUNT
|