From e131d31486f982864307da92c48968a320ccabce Mon Sep 17 00:00:00 2001 From: Misakait Date: Sat, 4 Oct 2025 17:44:11 +0800 Subject: [PATCH] test(ptx): Add regression test for stdin reference format --- tests/by-util/test_ptx.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index 7fd40db76..917cd047a 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -10,7 +10,25 @@ use uutests::new_ucmd; fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails_with_code(1); } - +#[test] +fn test_reference_format_for_stdin() { + let input = "Rust is good language"; + let expected_output = concat!( + r#".xx "" "" "Rust is good language" "" ":1""#, + "\n", + r#".xx "" "Rust is" "good language" "" ":1""#, + "\n", + r#".xx "" "Rust" "is good language" "" ":1""#, + "\n", + r#".xx "" "Rust is good" "language" "" ":1""#, + "\n", + ); + new_ucmd!() + .args(&["-G", "-A"]) + .pipe_in(input) + .succeeds() + .stdout_only(expected_output); +} #[test] fn test_tex_format_no_truncation_markers() { let input = "Hello world Rust is a fun language";