Skip to content

Commit 500cf66

Browse files
committed
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
1 parent c318aee commit 500cf66

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

src/test/regress/expected/float8-exp-three-digits-win32.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ SELECT '-10e-400'::float8;
2424
ERROR: "-10e-400" is out of range for type double precision
2525
LINE 1: SELECT '-10e-400'::float8;
2626
^
27+
-- test whether denormalized values are accepted
28+
SELECT '4.95e-324'::float8 < '1.49e-323'::float8;
29+
?column?
30+
----------
31+
t
32+
(1 row)
33+
34+
SELECT '4.95e-324'::float8 > '0'::float8;
35+
?column?
36+
----------
37+
t
38+
(1 row)
39+
40+
SELECT substr('-4.95e-324'::float8::text, 1, 4);
41+
substr
42+
--------
43+
-4.9
44+
(1 row)
45+
2746
-- bad input
2847
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
2948
ERROR: invalid input syntax for type double precision: ""

src/test/regress/expected/float8-small-is-zero.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ SELECT '10e-400'::float8;
2424

2525
SELECT '-10e-400'::float8;
2626
float8
27+
-- test whether denormalized values are accepted
28+
SELECT '4.95e-324'::float8 < '1.49e-323'::float8;
29+
?column?
30+
----------
31+
t
32+
(1 row)
33+
34+
SELECT '4.95e-324'::float8 > '0'::float8;
35+
?column?
36+
----------
37+
t
38+
(1 row)
39+
40+
SELECT substr('-4.95e-324'::float8::text, 1, 4);
41+
substr
42+
--------
43+
-4.9
44+
(1 row)
45+
2746
--------
2847
-0
2948
(1 row)

src/test/regress/expected/float8-small-is-zero_1.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ SELECT '10e-400'::float8;
2424

2525
SELECT '-10e-400'::float8;
2626
float8
27+
-- test whether denormalized values are accepted
28+
SELECT '4.95e-324'::float8 < '1.49e-323'::float8;
29+
?column?
30+
----------
31+
t
32+
(1 row)
33+
34+
SELECT '4.95e-324'::float8 > '0'::float8;
35+
?column?
36+
----------
37+
t
38+
(1 row)
39+
40+
SELECT substr('-4.95e-324'::float8::text, 1, 4);
41+
substr
42+
--------
43+
-4.9
44+
(1 row)
45+
2746
--------
2847
0
2948
(1 row)

src/test/regress/expected/float8.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ SELECT '-10e-400'::float8;
2424
ERROR: "-10e-400" is out of range for type double precision
2525
LINE 1: SELECT '-10e-400'::float8;
2626
^
27+
-- test whether denormalized values are accepted
28+
SELECT '4.95e-324'::float8 < '1.49e-323'::float8;
29+
?column?
30+
----------
31+
t
32+
(1 row)
33+
34+
SELECT '4.95e-324'::float8 > '0'::float8;
35+
?column?
36+
----------
37+
t
38+
(1 row)
39+
40+
SELECT substr('-4.95e-324'::float8::text, 1, 4);
41+
substr
42+
--------
43+
-4.9
44+
(1 row)
45+
2746
-- bad input
2847
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
2948
ERROR: invalid input syntax for type double precision: ""

src/test/regress/sql/float8.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ SELECT '-10e400'::float8;
1616
SELECT '10e-400'::float8;
1717
SELECT '-10e-400'::float8;
1818

19+
-- test whether denormalized values are accepted
20+
SELECT '4.95e-324'::float8 < '1.49e-323'::float8;
21+
SELECT '4.95e-324'::float8 > '0'::float8;
22+
SELECT substr('-4.95e-324'::float8::text, 1, 4);
23+
1924
-- bad input
2025
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
2126
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');

0 commit comments

Comments
 (0)