From 80d0e5ba3fe03890831b425e85d10150e226239e Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 28 Aug 2019 12:28:16 +0900 Subject: [PATCH] Improve coverage of utils/float.h check_float4_val() checks after underflow and overflow of values converted from float8 to float4, but there has never been any regression tests for that. This brings the coverage of float.h to 100%. Author: Movead Li Discussion: https://postgr.es/m/20190822174636998766188@highgo.ca --- src/test/regress/expected/float4-misrounded-input.out | 8 ++++++++ src/test/regress/expected/float4.out | 8 ++++++++ src/test/regress/sql/float4.sql | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/src/test/regress/expected/float4-misrounded-input.out b/src/test/regress/expected/float4-misrounded-input.out index d21e1fba1f..6c89af6394 100644 --- a/src/test/regress/expected/float4-misrounded-input.out +++ b/src/test/regress/expected/float4-misrounded-input.out @@ -24,6 +24,14 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); ERROR: "-10e-70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); ^ +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8); +ERROR: value out of range: overflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8); +ERROR: value out of range: overflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8); +ERROR: value out of range: underflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8); +ERROR: value out of range: underflow INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400'); ERROR: "10e400" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400'); diff --git a/src/test/regress/expected/float4.out b/src/test/regress/expected/float4.out index 901abb1d27..d6c22c1752 100644 --- a/src/test/regress/expected/float4.out +++ b/src/test/regress/expected/float4.out @@ -24,6 +24,14 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); ERROR: "-10e-70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); ^ +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8); +ERROR: value out of range: overflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8); +ERROR: value out of range: overflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8); +ERROR: value out of range: underflow +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8); +ERROR: value out of range: underflow INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400'); ERROR: "10e400" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400'); diff --git a/src/test/regress/sql/float4.sql b/src/test/regress/sql/float4.sql index afdb469dc8..393d98fb14 100644 --- a/src/test/regress/sql/float4.sql +++ b/src/test/regress/sql/float4.sql @@ -16,6 +16,11 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'); INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'); INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8); +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8); +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8); +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8); + INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400'); INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e400'); INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-400'); -- 2.40.0