summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2012-02-01 18:13:54 +0000
committerTom Lane2012-02-01 18:13:54 +0000
commit500cf66d5522b39ddfdc26b309f8b5b0e385f42e (patch)
tree9f3020e884aef689306cc9d506ec5279f952e618
parentc318aeed84438619fc6b8c647def1730a110f04b (diff)
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
-rw-r--r--src/test/regress/expected/float8-exp-three-digits-win32.out19
-rw-r--r--src/test/regress/expected/float8-small-is-zero.out19
-rw-r--r--src/test/regress/expected/float8-small-is-zero_1.out19
-rw-r--r--src/test/regress/expected/float8.out19
-rw-r--r--src/test/regress/sql/float8.sql5
5 files changed, 81 insertions, 0 deletions
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 (' ');