1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Merge pull request #7777 from Qelxiros/7678-parsing-tests

add tests against '0 in sleep/timeout durations
This commit is contained in:
Sylvestre Ledru 2025-04-18 10:02:40 +02:00 committed by GitHub
commit 38ef20c385
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -305,7 +305,8 @@ fn test_valid_hex_duration(#[case] input: &str) {
#[case::wrong_capitalization("infD")] #[case::wrong_capitalization("infD")]
#[case::wrong_capitalization("INFD")] #[case::wrong_capitalization("INFD")]
#[case::wrong_capitalization("iNfD")] #[case::wrong_capitalization("iNfD")]
fn test_invalid_hex_duration(#[case] input: &str) { #[case::single_quote("'1")]
fn test_invalid_duration(#[case] input: &str) {
new_ucmd!() new_ucmd!()
.args(&["--", input]) .args(&["--", input])
.fails() .fails()

View file

@ -3,6 +3,9 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore dont // spell-checker:ignore dont
use rstest::rstest;
use uucore::display::Quotable;
use uutests::new_ucmd; use uutests::new_ucmd;
use uutests::util::TestScenario; use uutests::util::TestScenario;
use uutests::util_name; use uutests::util_name;
@ -22,12 +25,14 @@ fn test_subcommand_return_code() {
new_ucmd!().arg("1").arg("false").fails_with_code(1); new_ucmd!().arg("1").arg("false").fails_with_code(1);
} }
#[test] #[rstest]
fn test_invalid_time_interval() { #[case::alphabetic("xyz")]
#[case::single_quote("'1")]
fn test_invalid_time_interval(#[case] input: &str) {
new_ucmd!() new_ucmd!()
.args(&["xyz", "sleep", "0"]) .args(&[input, "sleep", "0"])
.fails_with_code(125) .fails_with_code(125)
.usage_error("invalid time interval 'xyz'"); .usage_error(format!("invalid time interval {}", input.quote()));
} }
#[test] #[test]