1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

test: printf: Add nan, inf, negative zero

Add a few end-to-end tests for printf of unusual floats (nan,
infinity, negative zero).
This commit is contained in:
Nicolas Boichat 2025-03-07 12:48:22 +01:00
parent b7dcaa34da
commit 92a291b71d

View file

@ -886,6 +886,30 @@ fn float_with_zero_precision_should_pad() {
.stdout_only("-01");
}
#[test]
fn float_non_finite() {
new_ucmd!()
.args(&[
"%f %f %F %f %f %F",
"nan",
"-nan",
"nan",
"inf",
"-inf",
"inf",
])
.succeeds()
.stdout_only("nan -nan NAN inf -inf INF");
}
#[test]
fn float_zero_neg_zero() {
new_ucmd!()
.args(&["%f %f", "0.0", "-0.0"])
.succeeds()
.stdout_only("0.000000 -0.000000");
}
#[test]
fn precision_check() {
new_ucmd!()