From 1782de89994f8e967a6ab522e1c735cafa02668a Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 3 Mar 2025 15:07:38 +0100 Subject: [PATCH] seq: Add tests for default float formats Add tests for some of the default float formats (%f, %g, %E), mostly to check that the default precision is correctly set to 6 digits. --- tests/by-util/test_seq.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 0c708506f..716b5cb88 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -708,6 +708,30 @@ fn test_format_option() { .stdout_only("0.00\n0.10\n0.20\n0.30\n0.40\n0.50\n"); } +#[test] +fn test_format_option_default_precision() { + new_ucmd!() + .args(&["-f", "%f", "0", "0.7", "2"]) + .succeeds() + .stdout_only("0.000000\n0.700000\n1.400000\n"); +} + +#[test] +fn test_format_option_default_precision_short() { + new_ucmd!() + .args(&["-f", "%g", "0", "0.987654321", "2"]) + .succeeds() + .stdout_only("0\n0.987654\n1.97531\n"); +} + +#[test] +fn test_format_option_default_precision_scientific() { + new_ucmd!() + .args(&["-f", "%E", "0", "0.7", "2"]) + .succeeds() + .stdout_only("0.000000E+00\n7.000000E-01\n1.400000E+00\n"); +} + #[test] #[ignore = "Need issue #2660 to be fixed"] fn test_auto_precision() {