Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3d2844

Browse files
committed
Improve test coverage of geometric types
This commit significantly increases test coverage of geo_ops.c, addingtests for various issues addressed by2e2a392 (which went undetectedfor a long time, at least partially due to not being covered).This also removes alternative results expecting -0 on some platforms.Instead the functions are should return the same results everywhere,transforming -0 to 0 if needed.The tests are added to geometric.sql file, sorted by the left hand sideof the operators. There are many cross datatype operators, so this seemslike the best solution.Author: Emre HasegeliReviewed-by: Tomas VondraDiscussion:https://www.postgresql.org/message-id/CAE2gYzxF7-5djV6-cEvqQu-fNsnt%3DEqbOURx7ZDg%2BVv6ZMTWbg%40mail.gmail.com
1 parent2e2a392 commita3d2844

19 files changed

+10088
-1926
lines changed

‎src/test/regress/expected/box.out

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CREATE TABLE BOX_TBL (f1 box);
1919
INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
2020
INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
21+
INSERT INTO BOX_TBL (f1) VALUES ('((-8, 2), (-2, -10))');
2122
-- degenerate cases where the box is a line or a point
2223
-- note that lines and points boxes all have zero area
2324
INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
@@ -27,6 +28,18 @@ INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
2728
ERROR: invalid input syntax for type box: "(2.3, 4.5)"
2829
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
2930
^
31+
INSERT INTO BOX_TBL (f1) VALUES ('[1, 2, 3, 4)');
32+
ERROR: invalid input syntax for type box: "[1, 2, 3, 4)"
33+
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('[1, 2, 3, 4)');
34+
^
35+
INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4]');
36+
ERROR: invalid input syntax for type box: "(1, 2, 3, 4]"
37+
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4]');
38+
^
39+
INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4) x');
40+
ERROR: invalid input syntax for type box: "(1, 2, 3, 4) x"
41+
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4) x');
42+
^
3043
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
3144
ERROR: invalid input syntax for type box: "asdfasdf(ad"
3245
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
@@ -36,19 +49,21 @@ SELECT '' AS four, * FROM BOX_TBL;
3649
------+---------------------
3750
| (2,2),(0,0)
3851
| (3,3),(1,1)
52+
| (-2,2),(-8,-10)
3953
| (2.5,3.5),(2.5,2.5)
4054
| (3,3),(3,3)
41-
(4 rows)
55+
(5 rows)
4256

4357
SELECT '' AS four, b.*, area(b.f1) as barea
4458
FROM BOX_TBL b;
4559
four | f1 | barea
4660
------+---------------------+-------
4761
| (2,2),(0,0) | 4
4862
| (3,3),(1,1) | 4
63+
| (-2,2),(-8,-10) | 72
4964
| (2.5,3.5),(2.5,2.5) | 0
5065
| (3,3),(3,3) | 0
51-
(4 rows)
66+
(5 rows)
5267

5368
-- overlap
5469
SELECT '' AS three, b.f1
@@ -68,8 +83,9 @@ SELECT '' AS two, b1.*
6883
two | f1
6984
-----+---------------------
7085
| (2,2),(0,0)
86+
| (-2,2),(-8,-10)
7187
| (2.5,3.5),(2.5,2.5)
72-
(2 rows)
88+
(3 rows)
7389

7490
-- right-or-overlap (x only)
7591
SELECT '' AS two, b1.*
@@ -88,8 +104,9 @@ SELECT '' AS two, b.f1
88104
two | f1
89105
-----+---------------------
90106
| (2,2),(0,0)
107+
| (-2,2),(-8,-10)
91108
| (2.5,3.5),(2.5,2.5)
92-
(2 rows)
109+
(3 rows)
93110

94111
-- area <=
95112
SELECT '' AS four, b.f1
@@ -127,11 +144,12 @@ SELECT '' AS two, b.f1
127144
SELECT '' AS two, b.f1
128145
FROM BOX_TBL b-- zero area
129146
WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
130-
two |f1
131-
-----+-------------
147+
two | f1
148+
-----+-----------------
132149
| (2,2),(0,0)
133150
| (3,3),(1,1)
134-
(2 rows)
151+
| (-2,2),(-8,-10)
152+
(3 rows)
135153

136154
-- area >=
137155
SELECT '' AS four, b.f1
@@ -141,9 +159,10 @@ SELECT '' AS four, b.f1
141159
------+---------------------
142160
| (2,2),(0,0)
143161
| (3,3),(1,1)
162+
| (-2,2),(-8,-10)
144163
| (2.5,3.5),(2.5,2.5)
145164
| (3,3),(3,3)
146-
(4 rows)
165+
(5 rows)
147166

148167
-- right of
149168
SELECT '' AS two, b.f1
@@ -152,8 +171,9 @@ SELECT '' AS two, b.f1
152171
two | f1
153172
-----+---------------------
154173
| (2,2),(0,0)
174+
| (-2,2),(-8,-10)
155175
| (2.5,3.5),(2.5,2.5)
156-
(2 rows)
176+
(3 rows)
157177

158178
-- contained in
159179
SELECT '' AS three, b.f1
@@ -193,9 +213,10 @@ SELECT '' AS four, @@(b1.f1) AS p
193213
------+---------
194214
| (1,1)
195215
| (2,2)
216+
| (-5,-4)
196217
| (2.5,3)
197218
| (3,3)
198-
(4 rows)
219+
(5 rows)
199220

200221
-- wholly-contained
201222
SELECT '' AS one, b1.*, b2.*
@@ -211,9 +232,10 @@ SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
211232
------+--------+-------
212233
| 2 | 2
213234
| 2 | 2
235+
| 12 | 6
214236
| 1 | 0
215237
| 0 | 0
216-
(4 rows)
238+
(5 rows)
217239

218240
--
219241
-- Test the SP-GiST index

‎src/test/regress/expected/circle.out

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
77
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
88
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
99
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
10-
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
10+
INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ');
11+
INSERT INTO CIRCLE_TBL VALUES ('<(3,5),0>');-- Zero radius
12+
INSERT INTO CIRCLE_TBL VALUES ('<(3,5),NaN>');-- NaN radius
1113
-- bad values
1214
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
1315
ERROR: invalid input syntax for type circle: "<(-100,0),-100>"
1416
LINE 1: INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
1517
^
18+
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10');
19+
ERROR: invalid input syntax for type circle: "<(100,200),10"
20+
LINE 1: INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10');
21+
^
22+
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10> x');
23+
ERROR: invalid input syntax for type circle: "<(100,200),10> x"
24+
LINE 1: INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10> x');
25+
^
1626
INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
1727
ERROR: invalid input syntax for type circle: "1abc,3,5"
1828
LINE 1: INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
@@ -30,7 +40,9 @@ SELECT * FROM CIRCLE_TBL;
3040
<(1,2),3>
3141
<(100,200),10>
3242
<(100,1),115>
33-
(6 rows)
43+
<(3,5),0>
44+
<(3,5),NaN>
45+
(8 rows)
3446

3547
SELECT '' AS six, center(f1) AS center
3648
FROM CIRCLE_TBL;
@@ -42,7 +54,9 @@ SELECT '' AS six, center(f1) AS center
4254
| (1,2)
4355
| (100,200)
4456
| (100,1)
45-
(6 rows)
57+
| (3,5)
58+
| (3,5)
59+
(8 rows)
4660

4761
SELECT '' AS six, radius(f1) AS radius
4862
FROM CIRCLE_TBL;
@@ -54,7 +68,9 @@ SELECT '' AS six, radius(f1) AS radius
5468
| 3
5569
| 10
5670
| 115
57-
(6 rows)
71+
| 0
72+
| NaN
73+
(8 rows)
5874

5975
SELECT '' AS six, diameter(f1) AS diameter
6076
FROM CIRCLE_TBL;
@@ -66,14 +82,17 @@ SELECT '' AS six, diameter(f1) AS diameter
6682
| 6
6783
| 20
6884
| 230
69-
(6 rows)
85+
| 0
86+
| NaN
87+
(8 rows)
7088

7189
SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
7290
two | f1
7391
-----+-----------
7492
| <(5,1),3>
7593
| <(1,2),3>
76-
(2 rows)
94+
| <(3,5),0>
95+
(3 rows)
7796

7897
SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
7998
four | f1
@@ -82,18 +101,22 @@ SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
82101
| <(1,3),5>
83102
| <(100,200),10>
84103
| <(100,1),115>
85-
(4 rows)
104+
| <(3,5),NaN>
105+
(5 rows)
86106

87107
SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
88108
FROM CIRCLE_TBL c1, CIRCLE_TBL c2
89109
WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0)
90110
ORDER BY distance, area(c1.f1), area(c2.f1);
91111
five | one | two | distance
92112
------+----------------+----------------+------------------
113+
| <(3,5),0> | <(1,2),3> | 0.60555127546399
114+
| <(3,5),0> | <(5,1),3> | 1.47213595499958
93115
| <(100,200),10> | <(100,1),115> | 74
94116
| <(100,200),10> | <(1,2),100> | 111.370729772479
95117
| <(1,3),5> | <(100,200),10> | 205.476756144497
96118
| <(5,1),3> | <(100,200),10> | 207.51303816328
119+
| <(3,5),0> | <(100,200),10> | 207.793480159531
97120
| <(1,2),3> | <(100,200),10> | 208.370729772479
98-
(5 rows)
121+
(8 rows)
99122

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp