Skip to content

Commit ef3c4a8

Browse files
committed
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.
1 parent d9af784 commit ef3c4a8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/by-util/test_seq.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,30 @@ fn test_format_option() {
708708
.stdout_only("0.00\n0.10\n0.20\n0.30\n0.40\n0.50\n");
709709
}
710710

711+
#[test]
712+
fn test_format_option_default_precision() {
713+
new_ucmd!()
714+
.args(&["-f", "%f", "0", "0.7", "2"])
715+
.succeeds()
716+
.stdout_only("0.000000\n0.700000\n1.400000\n");
717+
}
718+
719+
#[test]
720+
fn test_format_option_default_precision_short() {
721+
new_ucmd!()
722+
.args(&["-f", "%g", "0", "0.987654321", "2"])
723+
.succeeds()
724+
.stdout_only("0\n0.987654\n1.97531\n");
725+
}
726+
727+
#[test]
728+
fn test_format_option_default_precision_scientific() {
729+
new_ucmd!()
730+
.args(&["-f", "%E", "0", "0.7", "2"])
731+
.succeeds()
732+
.stdout_only("0.000000E+00\n7.000000E-01\n1.400000E+00\n");
733+
}
734+
711735
#[test]
712736
#[ignore = "Need issue #2660 to be fixed"]
713737
fn test_auto_precision() {

0 commit comments

Comments
 (0)