Skip to content

Commit 65da681

Browse files
committed
add test for style test matcher
1 parent b545d3c commit 65da681

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Feature: Writing tests for lua styles
2+
This feature exercises the different steps and matcher
3+
of the osm2pgsql-test-style script.
4+
5+
Background:
6+
Given the OSM data
7+
"""
8+
n10 Tname=Afeat,access=yes x1 y4
9+
n11 Tname=B-feat-Ö,access=no x34.5 y-1.5
10+
"""
11+
And the style file 'flex-config/generic.lua'
12+
When running osm2pgsql flex
13+
14+
Scenario: Fields can be matched case-insensitive
15+
Then table points contains
16+
| node_id | tags->'name'!i |
17+
| 10 | AFEAT |
18+
| 11 | b-feat-ö |
19+
And table points doesn't contain
20+
| node_id | tags->'name' |
21+
| 10 | AFEAT |
22+
23+
24+
Scenario: Fields can be match with a regular expression
25+
Then table points contains
26+
| node_id | tags!re |
27+
| 10 | .*access.* |
28+
| 11 | .*-[a-z]+-.* |
29+
30+
31+
Scenario: Fields can be matched as a substring
32+
Then table points contains
33+
| node_id | tags->'name'!substr |
34+
| 10 | feat |
35+
| 11 | feat |
36+
And table points doesn't contain
37+
| node_id | tags->'name' |
38+
| 10 | ? |
39+
40+
41+
Scenario: Fields can be matched as a json expression
42+
Then table points contains
43+
| node_id | tags!json |
44+
| 10 | {"name": "Afeat", "access": "yes"} |
45+
Then table points contains
46+
| node_id | tags!json |
47+
| 10 | {"access": "yes", "name": "Afeat"} |
48+
49+
50+
Scenario: Floating fields can be matched with different precision
51+
Then table points contains
52+
| node_id | ST_X(geom)!~0.5 |
53+
| 11 | 3840522.0 |
54+
Then table points doesn't contain
55+
| node_id | ST_X(geom)!~0.1 |
56+
| 11 | 3840522.0 |
57+
Then table points contains
58+
| node_id | ST_X(geom)!~1% |
59+
| 11 | 3840000.0 |
60+
Then table points doesn't contain
61+
| node_id | ST_X(geom)!~0.01% |
62+
| 11 | 3840000.0 |
63+
64+
65+
Scenario: Fields can be formatted arbitrarily for comparison
66+
Then table points contains
67+
| node_id!:03d | ST_X(geom)!:.1f |
68+
| 010 | 111319.5 |

0 commit comments

Comments
 (0)