1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

nl: add test for "--number-separator"

and replace "match" with "if let"
This commit is contained in:
Daniel Hofstetter 2023-07-12 15:25:02 +02:00
parent 5d2a2954be
commit 20b1f11daa
2 changed files with 13 additions and 5 deletions

View file

@ -30,11 +30,8 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) ->
// This vector holds error messages encountered.
let mut errs: Vec<String> = vec![];
settings.renumber = opts.get_flag(options::NO_RENUMBER);
match opts.get_one::<String>(options::NUMBER_SEPARATOR) {
None => {}
Some(val) => {
settings.number_separator = val.to_owned();
}
if let Some(val) = opts.get_one::<String>(options::NUMBER_SEPARATOR) {
settings.number_separator = val.to_owned();
}
settings.number_format = opts
.get_one::<String>(options::NUMBER_FORMAT)

View file

@ -156,3 +156,14 @@ fn test_invalid_number_width() {
.stderr_contains("invalid value 'invalid'");
}
}
#[test]
fn test_number_separator() {
for arg in ["-s:-:", "--number-separator=:-:"] {
new_ucmd!()
.arg(arg)
.pipe_in("test")
.succeeds()
.stdout_is(" 1:-:test\n");
}
}