numfmt: honor LC_NUMERIC for decimal separator (#11941)

* numfmt: honor LC_NUMERIC for decimal separator

* fixing clippy warning

* fix spell-checker and skip locale tests on WASI
This commit is contained in:
viju
2026-04-22 15:53:07 +02:00
committed by GitHub
parent 39c3646036
commit b3469aeef6
2 changed files with 106 additions and 31 deletions
+43
View File
@@ -1470,3 +1470,46 @@ fn test_invalid_utf8_input() {
.stdout_is("10\n")
.stderr_is("numfmt: invalid number: '\\377'\n");
}
#[test]
#[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")]
fn test_locale_fr_output() {
// Output uses the locale separator
new_ucmd!()
.env("LC_ALL", "fr_FR.UTF-8")
.args(&["--to=iec", "1500"])
.succeeds()
.stdout_is("1,5K\n");
}
#[test]
#[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")]
fn test_locale_fr_input_comma() {
// fr_FR should take '1,5' as a number
new_ucmd!()
.env("LC_ALL", "fr_FR.UTF-8")
.args(&["--format=%.3f", "1,5"])
.succeeds()
.stdout_is("1,500\n");
}
#[test]
#[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")]
fn test_locale_fr_rejects_period() {
// '.' isn't valid in fr_FR, should bail
new_ucmd!()
.env("LC_ALL", "fr_FR.UTF-8")
.args(&["--format=%.3f", "1.5"])
.fails()
.stderr_contains("invalid");
}
#[test]
fn test_locale_c_uses_period() {
// C locale should still use '.' as usual
new_ucmd!()
.env("LC_ALL", "C")
.args(&["--to=iec", "1500"])
.succeeds()
.stdout_is("1.5K\n");
}