1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

join: implement the -o option

This commit is contained in:
Konstantin Pospelov 2018-01-06 22:49:07 +03:00
parent 49cf7c2a5b
commit 12c5c951fb
5 changed files with 259 additions and 58 deletions

View file

@ -0,0 +1,5 @@
1 a a
2 b b
3 c d
4 d g
5 e i

View file

@ -0,0 +1,5 @@
1 a
2 b c
3 d e f
4 g h
5 i

View file

@ -0,0 +1,6 @@
f 2 a
g 3 b
h 4 c
i 5 f
j 6 g
k 7 h

View file

@ -124,3 +124,52 @@ fn multitab_character() {
.arg("э")
.fails().stderr_is("join: error: multi-character tab э");
}
#[test]
fn default_format() {
new_ucmd!()
.arg("fields_1.txt")
.arg("fields_2.txt")
.arg("-o")
.arg("1.1 2.2")
.succeeds().stdout_only_fixture("default.expected");
new_ucmd!()
.arg("fields_1.txt")
.arg("fields_2.txt")
.arg("-o")
.arg("0 2.2")
.succeeds().stdout_only_fixture("default.expected");
}
#[test]
fn unpaired_lines_format() {
new_ucmd!()
.arg("fields_2.txt")
.arg("fields_3.txt")
.arg("-a")
.arg("2")
.arg("-o")
.arg("1.2 1.1 2.4 2.3 2.2 0")
.succeeds().stdout_only_fixture("unpaired_lines_format.expected");
}
#[test]
fn autoformat() {
new_ucmd!()
.arg("fields_2.txt")
.arg("different_lengths.txt")
.arg("-o")
.arg("auto")
.succeeds().stdout_only_fixture("autoformat.expected");
}
#[test]
fn empty_format() {
new_ucmd!()
.arg("fields_1.txt")
.arg("fields_2.txt")
.arg("-o")
.arg("")
.fails().stderr_is("join: error: invalid file number in field spec: ''");
}