Skip to content

Commit 12222a5

Browse files
committed
test: add locale-aware decimal separator test for sort -g
Add test to verify that sort's general numeric (-g) option correctly handles decimal separators based on locale settings, ensuring proper ordering of numbers like "1,9" vs "1,10" in French locale (comma as separator).
1 parent b3a6323 commit 12222a5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/by-util/test_sort.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,32 @@ fn test_g_float() {
15591559
.stdout_is(output);
15601560
}
15611561

1562+
#[test]
1563+
fn test_g_float_locale_decimal_separator() {
1564+
let Ok(locale_fr_utf8) = env::var("LOCALE_FR_UTF8") else {
1565+
return;
1566+
};
1567+
if locale_fr_utf8 == "none" {
1568+
return;
1569+
}
1570+
1571+
let ts = TestScenario::new("sort");
1572+
1573+
ts.ucmd()
1574+
.env("LC_ALL", &locale_fr_utf8)
1575+
.args(&["-g", "--stable"])
1576+
.pipe_in("1,9\n1,10\n")
1577+
.succeeds()
1578+
.stdout_is("1,10\n1,9\n");
1579+
1580+
ts.ucmd()
1581+
.env("LC_ALL", &locale_fr_utf8)
1582+
.args(&["-g", "--stable"])
1583+
.pipe_in("1.9\n1.10\n")
1584+
.succeeds()
1585+
.stdout_is("1.10\n1.9\n");
1586+
}
1587+
15621588
#[test]
15631589
// Test misc numbers ("'a" is not interpreted as literal, trailing text is ignored...)
15641590
fn test_g_misc() {

0 commit comments

Comments
 (0)