Skip to content

Commit

Permalink
Merge pull request #3081 from HeroicKatora/main
Browse files Browse the repository at this point in the history
Discuss seq parsing
  • Loading branch information
tertsdiepraam authored Mar 3, 2022
2 parents 66e9956 + a2e9329 commit 618a268
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.setting(AppSettings::TrailingVarArg)
.setting(AppSettings::AllowHyphenValues)
.setting(AppSettings::AllowNegativeNumbers)
.setting(AppSettings::InferLongArgs)
.version(crate_version!())
.about(ABOUT)
Expand Down
35 changes: 31 additions & 4 deletions tests/by-util/test_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ fn test_hex_rejects_sign_after_identifier() {
.args(&["-0x-123ABC"])
.fails()
.no_stdout()
.stderr_contains("invalid floating point argument: '-0x-123ABC'")
.stderr_contains("for more information.");
.stderr_contains("which wasn't expected, or isn't valid in this context")
.stderr_contains("For more information try --help");
new_ucmd!()
.args(&["-0x+123ABC"])
.fails()
.no_stdout()
.stderr_contains("invalid floating point argument: '-0x+123ABC'")
.stderr_contains("for more information.");
.stderr_contains("which wasn't expected, or isn't valid in this context")
.stderr_contains("For more information try --help");
}

#[test]
Expand Down Expand Up @@ -81,6 +81,33 @@ fn test_rejects_non_floats() {
.usage_error("invalid floating point argument: 'foo'");
}

#[test]
fn test_accepts_option_argument_directly() {
new_ucmd!()
.arg("-s,")
.arg("2")
.succeeds()
.stdout_is("1,2\n");
}

#[test]
fn test_option_with_detected_negative_argument() {
new_ucmd!()
.arg("-s,")
.args(&["-1", "2"])
.succeeds()
.stdout_is("-1,0,1,2\n");
}

#[test]
fn test_negative_number_as_separator() {
new_ucmd!()
.arg("-s")
.args(&["-1", "2"])
.succeeds()
.stdout_is("1-12\n");
}

#[test]
fn test_invalid_float() {
new_ucmd!()
Expand Down

0 comments on commit 618a268

Please sign in to comment.