From 66733ca99491dd7486300f1db1cb7fc2ba1e29da Mon Sep 17 00:00:00 2001 From: Andreas Molzer Date: Thu, 3 Feb 2022 23:44:43 +0100 Subject: [PATCH 1/2] seq: Add difficult cases to test suite --- tests/by-util/test_seq.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 5adbc292e..ad3086b03 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -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!() From a2e93299186be1911d1173cff8ea7f6163fa8f0f Mon Sep 17 00:00:00 2001 From: Andreas Molzer Date: Sun, 6 Feb 2022 03:46:31 +0100 Subject: [PATCH 2/2] seq: Allow option to receive immediate arguments WIP: this needs to be adjusted --- src/uu/seq/src/seq.rs | 2 +- tests/by-util/test_seq.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index af961a493..ec437dd40 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -146,7 +146,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) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index ad3086b03..a18cbc2ad 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -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]