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

numfmt: prohibit --header=0 to align with GNU

Adjust header option handling to prohibit passing a value of 0 to align
with GNU numfmt. Also report header option parse errors as GNU does.

closes #1708
This commit is contained in:
Daniel Rocco 2021-02-14 18:25:28 -05:00 committed by Sylvestre Ledru
parent f8006f47df
commit f595164063
2 changed files with 42 additions and 12 deletions

View file

@ -107,6 +107,30 @@ fn test_header_default() {
.stdout_is("header\n1000\n1100000\n100000000\n");
}
#[test]
fn test_header_error_if_non_numeric() {
new_ucmd!()
.args(&["--header=two"])
.run()
.stderr_is("numfmt: invalid header value two");
}
#[test]
fn test_header_error_if_0() {
new_ucmd!()
.args(&["--header=0"])
.run()
.stderr_is("numfmt: invalid header value 0");
}
#[test]
fn test_header_error_if_negative() {
new_ucmd!()
.args(&["--header=-3"])
.run()
.stderr_is("numfmt: invalid header value -3");
}
#[test]
fn test_negative() {
new_ucmd!()