Skip to content

Commit 38ef20c

Browse files
authored
Merge pull request #7777 from Qelxiros/7678-parsing-tests
add tests against '0 in sleep/timeout durations
2 parents 6cccd34 + 5bcc56a commit 38ef20c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tests/by-util/test_sleep.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ fn test_valid_hex_duration(#[case] input: &str) {
305305
#[case::wrong_capitalization("infD")]
306306
#[case::wrong_capitalization("INFD")]
307307
#[case::wrong_capitalization("iNfD")]
308-
fn test_invalid_hex_duration(#[case] input: &str) {
308+
#[case::single_quote("'1")]
309+
fn test_invalid_duration(#[case] input: &str) {
309310
new_ucmd!()
310311
.args(&["--", input])
311312
.fails()

tests/by-util/test_timeout.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
// spell-checker:ignore dont
6+
use rstest::rstest;
7+
8+
use uucore::display::Quotable;
69
use uutests::new_ucmd;
710
use uutests::util::TestScenario;
811
use uutests::util_name;
@@ -22,12 +25,14 @@ fn test_subcommand_return_code() {
2225
new_ucmd!().arg("1").arg("false").fails_with_code(1);
2326
}
2427

25-
#[test]
26-
fn test_invalid_time_interval() {
28+
#[rstest]
29+
#[case::alphabetic("xyz")]
30+
#[case::single_quote("'1")]
31+
fn test_invalid_time_interval(#[case] input: &str) {
2732
new_ucmd!()
28-
.args(&["xyz", "sleep", "0"])
33+
.args(&[input, "sleep", "0"])
2934
.fails_with_code(125)
30-
.usage_error("invalid time interval 'xyz'");
35+
.usage_error(format!("invalid time interval {}", input.quote()));
3136
}
3237

3338
#[test]

0 commit comments

Comments
 (0)