From: Neil Conway <neilc@samurai.com>
Date: Wed, 24 Mar 2004 02:02:27 +0000 (+0000)
Subject: Update the float8 regression tests: they should now pass on FreeBSD 4.x
X-Git-Tag: REL8_0_0BETA1~926
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=533d0915cfeef2f8e89d73c685e7d9ab1b5e2047;p=postgresql

Update the float8 regression tests: they should now pass on FreeBSD 4.x
and (in theory) QNX. Thanks to Chris KL for the report.
---

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 db72898ba7..e64a46399a 100644
--- a/src/test/regress/expected/float8-exp-three-digits-win32.out
+++ b/src/test/regress/expected/float8-exp-three-digits-win32.out
@@ -7,14 +7,14 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
--- test for underflow and overflow
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
+-- test for underflow and overflow handling
+SELECT '10e400'::float8;
 ERROR:  "10e400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
+SELECT '-10e400'::float8;
 ERROR:  "-10e400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
+SELECT '10e-400'::float8;
 ERROR:  "10e-400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
+SELECT '-10e-400'::float8;
 ERROR:  "-10e-400" is out of range for type double precision
 -- bad input
 INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');
diff --git a/src/test/regress/expected/float8-exp-three-digits.out b/src/test/regress/expected/float8-exp-three-digits.out
index 8113a3bda8..7cfa2bec16 100644
--- a/src/test/regress/expected/float8-exp-three-digits.out
+++ b/src/test/regress/expected/float8-exp-three-digits.out
@@ -2,11 +2,86 @@
 -- FLOAT8
 --
 CREATE TABLE FLOAT8_TBL(f1 float8);
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('    0.0   ');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30  ');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('   -34.84');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
+-- test for underflow and overflow handling
+SELECT '10e400'::float8;
+ERROR:  "10e400" is out of range for type double precision
+SELECT '-10e400'::float8;
+ERROR:  "-10e400" is out of range for type double precision
+SELECT '10e-400'::float8;
+ERROR:  "10e-400" is out of range for type double precision
+SELECT '-10e-400'::float8;
+ERROR:  "-10e-400" is out of range for type double precision
+-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');
+ERROR:  invalid input syntax for type double precision: "     "
+INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
+ERROR:  invalid input syntax for type double precision: "xyz"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
+ERROR:  invalid input syntax for type double precision: "5.0.0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
+ERROR:  invalid input syntax for type double precision: "5 . 0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5.   0');
+ERROR:  invalid input syntax for type double precision: "5.   0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('    - 3');
+ERROR:  invalid input syntax for type double precision: "    - 3"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('123           5');
+ERROR:  invalid input syntax for type double precision: "123           5"
+-- special inputs
+SELECT 'NaN'::float8;
+ float8
+--------
+    NaN
+(1 row)
+SELECT 'nan'::float8;
+ float8
+--------
+    NaN
+(1 row)
+
+SELECT '   NAN  '::float8;
+ float8
+--------
+    NaN
+(1 row)
+
+SELECT 'infinity'::float8;
+ float8
+----------
+ Infinity
+(1 row)
+
+SELECT '          -INFINiTY   '::float8;
+  float8
+-----------
+ -Infinity
+(1 row)
+
+-- bad special inputs
+SELECT 'N A N'::float8;
+ERROR:  invalid input syntax for type double precision: "N A N"
+SELECT 'NaN x'::float8;
+ERROR:  invalid input syntax for type double precision: "NaN x"
+SELECT ' INFINITY    x'::float8;
+ERROR:  invalid input syntax for type double precision: " INFINITY    x"
+SELECT 'Infinity'::float8 + 100.0;
+ERROR:  type "double precision" value out of range: overflow
+SELECT 'Infinity'::float8 / 'Infinity'::float8;
+ ?column?
+----------
+      NaN
+(1 row)
+
+SELECT 'nan'::float8 / 'nan'::float8;
+ ?column?
+----------
+      NaN
+(1 row)
+
 SELECT '' AS five, FLOAT8_TBL.*;
  five |          f1          
 ------+----------------------
diff --git a/src/test/regress/expected/float8-small-is-zero.out b/src/test/regress/expected/float8-small-is-zero.out
index 618d4decb6..11eefa230b 100644
--- a/src/test/regress/expected/float8-small-is-zero.out
+++ b/src/test/regress/expected/float8-small-is-zero.out
@@ -2,11 +2,95 @@
 -- FLOAT8
 --
 CREATE TABLE FLOAT8_TBL(f1 float8);
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('    0.0   ');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30  ');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('   -34.84');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
+-- test for underflow and overflow handling
+SELECT '10e400'::float8;
+ERROR:  "10e400" is out of range for type double precision
+SELECT '-10e400'::float8;
+ERROR:  "-10e400" is out of range for type double precision
+SELECT '10e-400'::float8;
+ float8 
+--------
+     0
+(1 row)
+
+SELECT '-10e-400'::float8;
+ float8 
+--------
+    -0
+(1 row)
+
+-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');
+ERROR:  invalid input syntax for type double precision: "     "
+INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
+ERROR:  invalid input syntax for type double precision: "xyz"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
+ERROR:  invalid input syntax for type double precision: "5.0.0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
+ERROR:  invalid input syntax for type double precision: "5 . 0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('5.   0');
+ERROR:  invalid input syntax for type double precision: "5.   0"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('    - 3');
+ERROR:  invalid input syntax for type double precision: "    - 3"
+INSERT INTO FLOAT8_TBL(f1) VALUES ('123           5');
+ERROR:  invalid input syntax for type double precision: "123           5"
+-- special inputs
+SELECT 'NaN'::float8;
+ float8 
+--------
+    NaN
+(1 row)
+
+SELECT 'nan'::float8;
+ float8 
+--------
+    NaN
+(1 row)
+
+SELECT '   NAN  '::float8;
+ float8 
+--------
+    NaN
+(1 row)
+
+SELECT 'infinity'::float8;
+  float8  
+----------
+ Infinity
+(1 row)
+
+SELECT '          -INFINiTY   '::float8;
+  float8   
+-----------
+ -Infinity
+(1 row)
+
+-- bad special inputs
+SELECT 'N A N'::float8;
+ERROR:  invalid input syntax for type double precision: "N A N"
+SELECT 'NaN x'::float8;
+ERROR:  invalid input syntax for type double precision: "NaN x"
+SELECT ' INFINITY    x'::float8;
+ERROR:  invalid input syntax for type double precision: " INFINITY    x"
+SELECT 'Infinity'::float8 + 100.0;
+ERROR:  type "double precision" value out of range: overflow
+SELECT 'Infinity'::float8 / 'Infinity'::float8;
+ ?column? 
+----------
+      NaN
+(1 row)
+
+SELECT 'nan'::float8 / 'nan'::float8;
+ ?column? 
+----------
+      NaN
+(1 row)
+
 SELECT '' AS five, FLOAT8_TBL.*;
  five |          f1          
 ------+----------------------
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out
index 798a67c04f..03a493aaa4 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -7,14 +7,14 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30  ');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('   -34.84');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
--- test for underflow and overflow
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
+-- test for underflow and overflow handling
+SELECT '10e400'::float8;
 ERROR:  "10e400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
+SELECT '-10e400'::float8;
 ERROR:  "-10e400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
+SELECT '10e-400'::float8;
 ERROR:  "10e-400" is out of range for type double precision
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
+SELECT '-10e-400'::float8;
 ERROR:  "-10e-400" is out of range for type double precision
 -- bad input
 INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');
diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql
index 593df68a32..4c706099cd 100644
--- a/src/test/regress/sql/float8.sql
+++ b/src/test/regress/sql/float8.sql
@@ -10,11 +10,11 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('   -34.84');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
 INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
 
--- test for underflow and overflow
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
+-- test for underflow and overflow handling
+SELECT '10e400'::float8;
+SELECT '-10e400'::float8;
+SELECT '10e-400'::float8;
+SELECT '-10e-400'::float8;
 
 -- bad input
 INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');