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

nl: use value parser for "--number-format"

This commit is contained in:
Daniel Hofstetter 2023-07-10 07:25:04 +02:00
parent bf30cbf4f6
commit cb50208909
3 changed files with 63 additions and 18 deletions

View file

@ -1,3 +1,4 @@
// spell-checker:ignore ninvalid
use crate::common::util::TestScenario;
#[test]
@ -78,3 +79,46 @@ fn test_no_renumber() {
new_ucmd!().arg(arg).succeeds();
}
}
#[test]
fn test_number_format_ln() {
for arg in ["-nln", "--number-format=ln"] {
new_ucmd!()
.arg(arg)
.pipe_in("test")
.succeeds()
.stdout_is("1 \ttest\n");
}
}
#[test]
fn test_number_format_rn() {
for arg in ["-nrn", "--number-format=rn"] {
new_ucmd!()
.arg(arg)
.pipe_in("test")
.succeeds()
.stdout_is(" 1\ttest\n");
}
}
#[test]
fn test_number_format_rz() {
for arg in ["-nrz", "--number-format=rz"] {
new_ucmd!()
.arg(arg)
.pipe_in("test")
.succeeds()
.stdout_is("000001\ttest\n");
}
}
#[test]
fn test_invalid_number_format() {
for arg in ["-ninvalid", "--number-format=invalid"] {
new_ucmd!()
.arg(arg)
.fails()
.stderr_contains("invalid value 'invalid'");
}
}