From d58f1cc0f1af515ea53de784efef29315615698b Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Fri, 21 Mar 2025 21:57:41 +0100 Subject: [PATCH] test_seq: Modify undefined behaviour tests GNU `seq` doesn't support such large positive exponents anyway, and we are limited by i64 range, so increase the exponent value to make sure we fully overflow that range. Also, add a test to check that a very, very, small number is treated as 0 (that's also undefined behaviour, but it does make sense in a way). --- tests/by-util/test_seq.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 83bdb7a82..01ccfc11f 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -752,21 +752,23 @@ fn test_undefined() { #[test] fn test_invalid_float_point_fail_properly() { + // Note that we support arguments that are much bigger than what GNU coreutils supports. + // Tests below use exponents larger than we support (i64) new_ucmd!() - .args(&["66000e000000000000000000000000000000000000000000000000000009223372036854775807"]) + .args(&["66000e0000000000000000000000000000000000000000000000000000092233720368547758070"]) .fails() .no_stdout() - .usage_error("invalid floating point argument: '66000e000000000000000000000000000000000000000000000000000009223372036854775807'"); + .usage_error("invalid floating point argument: '66000e0000000000000000000000000000000000000000000000000000092233720368547758070'"); new_ucmd!() - .args(&["-1.1e9223372036854775807"]) + .args(&["-1.1e92233720368547758070"]) .fails() .no_stdout() - .usage_error("invalid floating point argument: '-1.1e9223372036854775807'"); + .usage_error("invalid floating point argument: '-1.1e92233720368547758070'"); new_ucmd!() - .args(&["-.1e9223372036854775807"]) + .args(&["-.1e92233720368547758070"]) .fails() .no_stdout() - .usage_error("invalid floating point argument: '-.1e9223372036854775807'"); + .usage_error("invalid floating point argument: '-.1e92233720368547758070'"); } #[test]