Skip to content

Commit 3f135e1

Browse files
committed
test(ls): add comprehensive tests for --quoting-style=locale
Add test coverage for locale-aware quoting functionality: - Tests 10 different locales with appropriate quotation marks - Verifies English, French, German, Japanese, Chinese, Russian, Spanish, Polish, C, and POSIX locales - Tests escape sequence handling with locale quoting (newline character) - Validates UTF-8 encoding of multi-byte quote characters
1 parent c25f9cd commit 3f135e1

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/by-util/test_ls.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,6 +3723,57 @@ fn test_ls_quoting_style_arg_overrides_env_var() {
37233723
}
37243724
}
37253725

3726+
#[test]
3727+
fn test_ls_quoting_style_locale() {
3728+
let scene = TestScenario::new(util_name!());
3729+
let at = &scene.fixtures;
3730+
at.touch("file with spaces.txt");
3731+
3732+
// Test different locale-specific quote characters
3733+
// Each locale should use appropriate quotation marks for that language
3734+
let test_cases = vec![
3735+
// English - ASCII double quotes
3736+
("en_US.UTF-8", "\"file with spaces.txt\""),
3737+
// French - Guillemets (U+00AB, U+00BB)
3738+
("fr_FR.UTF-8", "«file with spaces.txt»"),
3739+
// German - Low-9 and high quotes (U+201E, U+201C)
3740+
("de_DE.UTF-8", "„file with spaces.txt“"),
3741+
// Japanese - Corner brackets (U+300C, U+300D)
3742+
("ja_JP.UTF-8", "「file with spaces.txt」"),
3743+
// Chinese - CJK curly quotes (U+201C, U+201D)
3744+
("zh_CN.UTF-8", "“file with spaces.txt”"),
3745+
// Russian - Guillemets (U+00AB, U+00BB)
3746+
("ru_RU.UTF-8", "«file with spaces.txt»"),
3747+
// Spanish - Guillemets (U+00AB, U+00BB)
3748+
("es_ES.UTF-8", "«file with spaces.txt»"),
3749+
// Polish - Low-9 double quotes (U+201E, U+201D)
3750+
("pl_PL.UTF-8", "„file with spaces.txt”"),
3751+
// Default/unset locale - ASCII double quotes
3752+
("C", "\"file with spaces.txt\""),
3753+
("POSIX", "\"file with spaces.txt\""),
3754+
];
3755+
3756+
for (locale, expected_output) in test_cases {
3757+
scene
3758+
.ucmd()
3759+
.env("LC_ALL", locale)
3760+
.arg("--quoting-style=locale")
3761+
.arg("file with spaces.txt")
3762+
.succeeds()
3763+
.stdout_only(format!("{expected_output}\n"));
3764+
}
3765+
3766+
// Test escape sequences work with locale quoting
3767+
at.touch("newline\nfile");
3768+
scene
3769+
.ucmd()
3770+
.env("LC_ALL", "fr_FR.UTF-8")
3771+
.arg("--quoting-style=locale")
3772+
.arg("newline\nfile")
3773+
.succeeds()
3774+
.stdout_only("«newline\\nfile»\n");
3775+
}
3776+
37263777
#[test]
37273778
fn test_ls_quoting_and_color() {
37283779
let scene = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)