mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
factor: emit GNU 9.11 'is not a valid positive integer' for stdin input (#12137)
* factor: emit GNU's 'X is not a valid positive integer' wording GNU's factor.c routes both stdin and command-line input through the same print_factors() and reports invalid input as factor: 'X' is not a valid positive integer Match that wording exactly so the new GNU 9.11 'nul4' test passes and the 'cont' test no longer needs the warning/invalid-digit hunk in tests_factor_factor.pl.patch. * Add 'cmdline' to spell-checker ignore list
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (methods) hexdigest funcs nprimes
|
||||
// spell-checker:ignore (methods) hexdigest funcs nprimes cmdline
|
||||
#![allow(
|
||||
clippy::similar_names,
|
||||
clippy::cast_possible_truncation,
|
||||
@@ -1678,10 +1678,10 @@ fn succeeds_with_numbers_larger_than_u256() {
|
||||
fn handles_non_unicode_data() {
|
||||
let input = b"\0 \xFF\0\xFF\xAA\0\xAA\x44 a\n6 9\x003\xC024\t2\t\t4\x000+4\xFF \xF7\xC1";
|
||||
let expected_out = "6: 2 3\n9: 3 3\n2: 2\n4: 2 2\n";
|
||||
let expected_err = r"factor: warning: '': invalid digit found in string
|
||||
factor: warning: '\377': invalid digit found in string
|
||||
factor: warning: 'a': invalid digit found in string
|
||||
factor: warning: '\367\301': invalid digit found in string
|
||||
let expected_err = r"factor: '' is not a valid positive integer
|
||||
factor: '\377' is not a valid positive integer
|
||||
factor: 'a' is not a valid positive integer
|
||||
factor: '\367\301' is not a valid positive integer
|
||||
";
|
||||
new_ucmd!()
|
||||
.pipe_in(input)
|
||||
@@ -1689,3 +1689,14 @@ factor: warning: '\367\301': invalid digit found in string
|
||||
.stdout_is(expected_out)
|
||||
.stderr_is(expected_err);
|
||||
}
|
||||
|
||||
// GNU's `tests/factor/factor.pl` `cont` test passes `factor a 4` and expects
|
||||
// `factor: 'a' is not a valid positive integer` while still factoring 4.
|
||||
#[test]
|
||||
fn invalid_cmdline_arg_continues() {
|
||||
new_ucmd!()
|
||||
.args(&["a", "4"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("4: 2 2\n")
|
||||
.stderr_is("factor: 'a' is not a valid positive integer\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user