cut: simplify type of COMPLEX_SEQUENCE in test (#12601)

use &str instead of TestedSequence struct

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
Daniel Hofstetter
2026-07-14 04:29:51 +02:00
committed by GitHub
parent 76d7a53fc4
commit 034efd2ca7
+8 -12
View File
@@ -5,8 +5,7 @@
// spell-checker:ignore defg
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::{at_and_ucmd, new_ucmd};
static INPUT: &str = "lists.txt";
@@ -42,10 +41,7 @@ static EXAMPLE_SEQUENCES: &[TestedSequence] = &[
},
];
static COMPLEX_SEQUENCE: &TestedSequence = &TestedSequence {
name: "",
sequence: "9-,6-7,-2,4",
};
const COMPLEX_SEQUENCE: &str = "9-,6-7,-2,4";
#[test]
fn test_no_args() {
@@ -99,7 +95,7 @@ fn test_field_sequence() {
#[test]
fn test_whitespace_delimited() {
new_ucmd!()
.args(&["-w", "-f", COMPLEX_SEQUENCE.sequence, INPUT])
.args(&["-w", "-f", COMPLEX_SEQUENCE, INPUT])
.succeeds()
.stdout_only_fixture("whitespace_delimited.expected");
}
@@ -107,21 +103,21 @@ fn test_whitespace_delimited() {
#[test]
fn test_whitespace_with_explicit_delimiter() {
new_ucmd!()
.args(&["-w", "-f", COMPLEX_SEQUENCE.sequence, "-d:"])
.args(&["-w", "-f", COMPLEX_SEQUENCE, "-d:"])
.fails_with_code(1);
}
#[test]
fn test_whitespace_with_byte() {
new_ucmd!()
.args(&["-w", "-b", COMPLEX_SEQUENCE.sequence])
.args(&["-w", "-b", COMPLEX_SEQUENCE])
.fails_with_code(1);
}
#[test]
fn test_whitespace_with_char() {
new_ucmd!()
.args(&["-c", COMPLEX_SEQUENCE.sequence, "-w"])
.args(&["-c", COMPLEX_SEQUENCE, "-w"])
.fails_with_code(1);
}
@@ -129,7 +125,7 @@ fn test_whitespace_with_char() {
fn test_delimiter_with_byte_and_char() {
for conflicting_arg in ["-c", "-b"] {
new_ucmd!()
.args(&[conflicting_arg, COMPLEX_SEQUENCE.sequence, "-d="])
.args(&[conflicting_arg, COMPLEX_SEQUENCE, "-d="])
.fails_with_code(1)
.stderr_is("cut: invalid input: The '--delimiter' ('-d') option can only be used when printing a sequence of fields\n")
;
@@ -148,7 +144,7 @@ fn test_too_large() {
fn test_delimiter() {
for param in ["-d", "--delimiter", "--del"] {
new_ucmd!()
.args(&[param, ":", "-f", COMPLEX_SEQUENCE.sequence, INPUT])
.args(&[param, ":", "-f", COMPLEX_SEQUENCE, INPUT])
.succeeds()
.stdout_only_fixture("delimiter_specified.expected");
}