Skip to content

Commit df212b1

Browse files
committed
pr: parameterize tests
1 parent 4de4228 commit df212b1

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

‎tests/by-util/test_pr.rs‎

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -841,36 +841,28 @@ fn test_simple_expand_tab_with_both_arguments() {
841841
#[test]
842842
fn test_invalid_expand_tab_arguments() {
843843
let test_file_path = "empty_test_file";
844-
// incorrect argument
845-
new_ucmd!()
846-
.args(&["-esdgjiojiosdgjiogd", test_file_path])
847-
.fails()
848-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘dgjiojiosdgjiogd’\nTry 'pr --help' for more information.");
849-
// non digit 2 parameter
850-
new_ucmd!()
851-
.args(&["-eab", test_file_path])
852-
.fails()
853-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘b’\nTry 'pr --help' for more information.");
854-
// non digit after first digit
855-
new_ucmd!()
856-
.args(&["-e1a", test_file_path])
857-
.fails()
858-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘1a’\nTry 'pr --help' for more information.");
859-
// non digit after first digit
860-
new_ucmd!()
861-
.args(&["-ea1a", test_file_path])
862-
.fails()
863-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘1a’\nTry 'pr --help' for more information.");
864-
// > i32 max
865-
new_ucmd!()
866-
.args(&["-e2147483648", test_file_path])
867-
.fails()
868-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘2147483648’\nTry 'pr --help' for more information.");
869-
// > i32 max after allowed input char
870-
new_ucmd!()
871-
.args(&["-ea2147483648", test_file_path])
872-
.fails()
873-
.stderr_contains("pr: '-e' extra characters or invalid number in the argument: ‘2147483648’\nTry 'pr --help' for more information.");
844+
845+
let test_cases = vec![
846+
// incorrect argument
847+
("-esdgjiojiosdgjiogd", "dgjiojiosdgjiogd"),
848+
// 2 non digit parameter
849+
("-eab", "b"),
850+
// non digit after first digit
851+
("-e1a", "1a"),
852+
// non digit after first digit after allowed input char
853+
("-ea1a", "1a"),
854+
// > i32 max
855+
("-e2147483648", "2147483648"),
856+
// > i32 max after allowed input char
857+
("-ea2147483648", "2147483648"),
858+
];
859+
860+
for (arg, error_msg_field) in test_cases {
861+
new_ucmd!()
862+
.args(&[arg, test_file_path])
863+
.fails()
864+
.stderr_contains(format!("pr: '-e' extra characters or invalid number in the argument: ‘{error_msg_field}’\nTry 'pr --help' for more information."));
865+
}
874866
}
875867
/* cSpell:enable */
876868

0 commit comments

Comments
 (0)