Skip to content

Commit 80d0e5b

Browse files
committed
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
1 parent be182e4 commit 80d0e5b

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/test/regress/expected/float4-misrounded-input.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
2424
ERROR: "-10e-70" is out of range for type real
2525
LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
2626
^
27+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8);
28+
ERROR: value out of range: overflow
29+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8);
30+
ERROR: value out of range: overflow
31+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8);
32+
ERROR: value out of range: underflow
33+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8);
34+
ERROR: value out of range: underflow
2735
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400');
2836
ERROR: "10e400" is out of range for type real
2937
LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400');

src/test/regress/expected/float4.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
2424
ERROR: "-10e-70" is out of range for type real
2525
LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
2626
^
27+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8);
28+
ERROR: value out of range: overflow
29+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8);
30+
ERROR: value out of range: overflow
31+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8);
32+
ERROR: value out of range: underflow
33+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8);
34+
ERROR: value out of range: underflow
2735
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400');
2836
ERROR: "10e400" is out of range for type real
2937
LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400');

src/test/regress/sql/float4.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70');
1616
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70');
1717
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
1818

19+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8);
20+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8);
21+
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8);
22+
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8);
23+
1924
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400');
2025
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e400');
2126
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-400');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy