From 500cf66d5522b39ddfdc26b309f8b5b0e385f42e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 1 Feb 2012 13:13:54 -0500 Subject: [PATCH] Add some regression test cases for denormalized float8 input. This was submitted with the previous patch, but I'm committing it separately to ease backing it out if these results prove too unportable. Marti Raudsepp, after a proposal by Jeroen Vermeulen --- .../float8-exp-three-digits-win32.out | 19 +++++++++++++++++++ .../regress/expected/float8-small-is-zero.out | 19 +++++++++++++++++++ .../expected/float8-small-is-zero_1.out | 19 +++++++++++++++++++ src/test/regress/expected/float8.out | 19 +++++++++++++++++++ src/test/regress/sql/float8.sql | 5 +++++ 5 files changed, 81 insertions(+) diff --git a/src/test/regress/expected/float8-exp-three-digits-win32.out b/src/test/regress/expected/float8-exp-three-digits-win32.out index 2dd648d6b9..fe97af0029 100644 --- a/src/test/regress/expected/float8-exp-three-digits-win32.out +++ b/src/test/regress/expected/float8-exp-three-digits-win32.out @@ -24,6 +24,25 @@ SELECT '-10e-400'::float8; ERROR: "-10e-400" is out of range for type double precision LINE 1: SELECT '-10e-400'::float8; ^ +-- test whether denormalized values are accepted +SELECT '4.95e-324'::float8 < '1.49e-323'::float8; + ?column? +---------- + t +(1 row) + +SELECT '4.95e-324'::float8 > '0'::float8; + ?column? +---------- + t +(1 row) + +SELECT substr('-4.95e-324'::float8::text, 1, 4); + substr +-------- + -4.9 +(1 row) + -- bad input INSERT INTO FLOAT8_TBL(f1) VALUES (''); ERROR: invalid input syntax for type double precision: "" diff --git a/src/test/regress/expected/float8-small-is-zero.out b/src/test/regress/expected/float8-small-is-zero.out index 5da743374c..2bf2e6ce60 100644 --- a/src/test/regress/expected/float8-small-is-zero.out +++ b/src/test/regress/expected/float8-small-is-zero.out @@ -24,6 +24,25 @@ SELECT '10e-400'::float8; SELECT '-10e-400'::float8; float8 +-- test whether denormalized values are accepted +SELECT '4.95e-324'::float8 < '1.49e-323'::float8; + ?column? +---------- + t +(1 row) + +SELECT '4.95e-324'::float8 > '0'::float8; + ?column? +---------- + t +(1 row) + +SELECT substr('-4.95e-324'::float8::text, 1, 4); + substr +-------- + -4.9 +(1 row) + -------- -0 (1 row) diff --git a/src/test/regress/expected/float8-small-is-zero_1.out b/src/test/regress/expected/float8-small-is-zero_1.out index 530842e102..b276eeca4f 100644 --- a/src/test/regress/expected/float8-small-is-zero_1.out +++ b/src/test/regress/expected/float8-small-is-zero_1.out @@ -24,6 +24,25 @@ SELECT '10e-400'::float8; SELECT '-10e-400'::float8; float8 +-- test whether denormalized values are accepted +SELECT '4.95e-324'::float8 < '1.49e-323'::float8; + ?column? +---------- + t +(1 row) + +SELECT '4.95e-324'::float8 > '0'::float8; + ?column? +---------- + t +(1 row) + +SELECT substr('-4.95e-324'::float8::text, 1, 4); + substr +-------- + -4.9 +(1 row) + -------- 0 (1 row) diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out index 6221538af5..df6ec9c58c 100644 --- a/src/test/regress/expected/float8.out +++ b/src/test/regress/expected/float8.out @@ -24,6 +24,25 @@ SELECT '-10e-400'::float8; ERROR: "-10e-400" is out of range for type double precision LINE 1: SELECT '-10e-400'::float8; ^ +-- test whether denormalized values are accepted +SELECT '4.95e-324'::float8 < '1.49e-323'::float8; + ?column? +---------- + t +(1 row) + +SELECT '4.95e-324'::float8 > '0'::float8; + ?column? +---------- + t +(1 row) + +SELECT substr('-4.95e-324'::float8::text, 1, 4); + substr +-------- + -4.9 +(1 row) + -- bad input INSERT INTO FLOAT8_TBL(f1) VALUES (''); ERROR: invalid input syntax for type double precision: "" diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql index 92a574ab7b..1f24556fed 100644 --- a/src/test/regress/sql/float8.sql +++ b/src/test/regress/sql/float8.sql @@ -16,6 +16,11 @@ SELECT '-10e400'::float8; SELECT '10e-400'::float8; SELECT '-10e-400'::float8; +-- test whether denormalized values are accepted +SELECT '4.95e-324'::float8 < '1.49e-323'::float8; +SELECT '4.95e-324'::float8 > '0'::float8; +SELECT substr('-4.95e-324'::float8::text, 1, 4); + -- bad input INSERT INTO FLOAT8_TBL(f1) VALUES (''); INSERT INTO FLOAT8_TBL(f1) VALUES (' '); -- 2.40.0