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

join: support headers

This commit is contained in:
Konstantin Pospelov 2018-04-11 22:55:44 +03:00
parent fc7b1fcaba
commit 7dc8ff62cc
6 changed files with 104 additions and 11 deletions

4
tests/fixtures/join/header.expected vendored Normal file
View file

@ -0,0 +1,4 @@
id field count
1 a abc 10
2 b abc 25
4 d 17 xyz

6
tests/fixtures/join/header_1.txt vendored Normal file
View file

@ -0,0 +1,6 @@
id field
1 a abc
2 b abc
3 c
4 d
5 c

5
tests/fixtures/join/header_2.txt vendored Normal file
View file

@ -0,0 +1,5 @@
id count
1 10
2 25
4 17 xyz
7 18 xyz

View file

@ -0,0 +1,4 @@
id field count
1 a 10
2 b 25
4 d 17

View file

@ -207,3 +207,38 @@ fn wrong_line_order() {
.arg("fields_4.txt")
.fails().stderr_is("fields_4.txt:5: is not sorted");
}
#[test]
fn headers() {
new_ucmd!()
.arg("header_1.txt")
.arg("header_2.txt")
.arg("--header")
.succeeds().stdout_only_fixture("header.expected");
}
#[test]
fn headers_autoformat() {
new_ucmd!()
.arg("header_1.txt")
.arg("header_2.txt")
.arg("--header")
.arg("-o")
.arg("auto")
.succeeds().stdout_only_fixture("header_autoformat.expected");
}
#[test]
fn single_file_with_header() {
new_ucmd!()
.arg("capitalized.txt")
.arg("empty.txt")
.arg("--header")
.succeeds().stdout_is("A 1");
new_ucmd!()
.arg("empty.txt")
.arg("capitalized.txt")
.arg("--header")
.succeeds().stdout_is("A 1");
}