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

Merge pull request #5073 from cakebaker/nl_add_test_for_number_separator

nl: add test for "--number-separator"
This commit is contained in:
Sylvestre Ledru 2023-07-12 22:42:01 +02:00 committed by GitHub
commit 1897c18e88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -30,12 +30,9 @@ 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) => {
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)
.map(Into::into)

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");
}
}