Skip to content

Commit

Permalink
Merge pull request #5073 from cakebaker/nl_add_test_for_number_separator
Browse files Browse the repository at this point in the history
nl: add test for "--number-separator"
  • Loading branch information
sylvestre authored Jul 12, 2023
2 parents bd4ecb6 + 20b1f11 commit 1897c18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/uu/nl/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tests/by-util/test_nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

0 comments on commit 1897c18

Please sign in to comment.