Skip to content

Commit e17e451

Browse files
committed
Changes to tests based on feedback in PR
1 parent 455e015 commit e17e451

File tree

2 files changed

+20
-68
lines changed

2 files changed

+20
-68
lines changed

tests/test-output-flex-way-change.cpp

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -145,66 +145,6 @@ TEST_CASE("change way from t1 and t2")
145145
CHECK(2 == conn.get_count("osm2pgsql_test_tboth"));
146146
}
147147

148-
TEST_CASE("change tboth with stage2 to tboth without stage2")
149-
{
150-
options_t options = testing::opt_t().slim().flex(conf_file);
151-
152-
testing::data_t data{tdata};
153-
data.add({"w10 v1 dV Ttboth=yes Nn10,n11",
154-
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
155-
156-
REQUIRE_NOTHROW(db.run_import(options, data()));
157-
158-
auto conn = db.db().connect();
159-
160-
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
161-
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
162-
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
163-
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
164-
"way_id = 10 AND rel_ids = '{30}'"));
165-
166-
options.append = true;
167-
168-
REQUIRE_NOTHROW(db.run_import(
169-
options, "r30 v2 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark"));
170-
171-
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
172-
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
173-
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
174-
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
175-
"way_id = 10 AND rel_ids IS NULL"));
176-
}
177-
178-
TEST_CASE("change tboth without stage2 to tboth with stage2")
179-
{
180-
options_t options = testing::opt_t().slim().flex(conf_file);
181-
182-
testing::data_t data{tdata};
183-
data.add({"w10 v1 dV Ttboth=yes Nn10,n11",
184-
"r30 v1 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark"});
185-
186-
REQUIRE_NOTHROW(db.run_import(options, data()));
187-
188-
auto conn = db.db().connect();
189-
190-
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
191-
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
192-
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
193-
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
194-
"way_id = 10 AND rel_ids IS NULL"));
195-
196-
options.append = true;
197-
198-
REQUIRE_NOTHROW(db.run_import(
199-
options, "r30 v2 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"));
200-
201-
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
202-
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
203-
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
204-
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
205-
"way_id = 10 AND rel_ids = '{30}'"));
206-
}
207-
208148
TEST_CASE("change valid geom to invalid geom")
209149
{
210150
options_t options = testing::opt_t().slim().flex(conf_file);
@@ -219,6 +159,8 @@ TEST_CASE("change valid geom to invalid geom")
219159

220160
CHECK(2 == conn.get_count("osm2pgsql_test_t1"));
221161
CHECK(2 == conn.get_count("osm2pgsql_test_t2"));
162+
CHECK(1 == conn.get_count("osm2pgsql_test_t2",
163+
"way_id = 10 AND rel_ids = '{30}'"));
222164
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
223165
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
224166
"way_id = 10 AND rel_ids = '{30}'"));
@@ -238,9 +180,9 @@ TEST_CASE("change valid geom to invalid geom")
238180

239181
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
240182
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
183+
CHECK(0 == conn.get_count("osm2pgsql_test_t2", "way_id = 10"));
241184
CHECK(2 == conn.get_count("osm2pgsql_test_tboth"));
242-
CHECK(0 == conn.get_count("osm2pgsql_test_tboth",
243-
"way_id = 10 AND rel_ids = '{30}'"));
185+
CHECK(0 == conn.get_count("osm2pgsql_test_tboth", "way_id = 10"));
244186
}
245187

246188
TEST_CASE("change invalid geom to valid geom")
@@ -257,9 +199,9 @@ TEST_CASE("change invalid geom to valid geom")
257199

258200
CHECK(1 == conn.get_count("osm2pgsql_test_t1"));
259201
CHECK(1 == conn.get_count("osm2pgsql_test_t2"));
202+
CHECK(0 == conn.get_count("osm2pgsql_test_t2", "way_id = 10"));
260203
CHECK(2 == conn.get_count("osm2pgsql_test_tboth"));
261-
CHECK(0 == conn.get_count("osm2pgsql_test_tboth",
262-
"way_id = 10 AND rel_ids = '{30}'"));
204+
CHECK(0 == conn.get_count("osm2pgsql_test_tboth", "way_id = 10"));
263205

264206
options.append = true;
265207

@@ -268,6 +210,8 @@ TEST_CASE("change invalid geom to valid geom")
268210

269211
CHECK(2 == conn.get_count("osm2pgsql_test_t1"));
270212
CHECK(2 == conn.get_count("osm2pgsql_test_t2"));
213+
CHECK(1 == conn.get_count("osm2pgsql_test_t2",
214+
"way_id = 10 AND rel_ids = '{30}'"));
271215
CHECK(3 == conn.get_count("osm2pgsql_test_tboth"));
272216
CHECK(1 == conn.get_count("osm2pgsql_test_tboth",
273217
"way_id = 10 AND rel_ids = '{30}'"));

tests/test-output-flex-way-relation-add.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ static const char *const tdata[] = {
2525
"w15 v1 dV Tt=ag Nn17,n19",
2626
"r30 v1 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark"};
2727

28-
// adding relation (marked)
28+
// adding relation (marked), also check case where relation changed to contain
29+
// the way under test
2930

3031
TEST_CASE("test way: add relation with way in t1 (marked)")
3132
{
@@ -130,14 +131,20 @@ TEST_CASE("test way: add relation with way in t1 and t2 (marked)")
130131
CHECK(0 == conn.get_count("osm2pgsql_test_tboth", "way_id = 10"));
131132
}
132133

133-
TEST_CASE("test way: add relation with way in tboth stage 1 (marked)")
134+
TEST_CASE("test way: add (to) relation with way in tboth stage 1 (marked)")
134135
{
135136
options_t options = testing::opt_t().slim().flex(conf_file);
136137

137138
testing::data_t data{tdata};
138139

139140
data.add("w10 v1 dV Ttboth=yes Nn10,n11");
140-
data.add("r31 v1 dV Tt=ag Mw10@");
141+
142+
SECTION("adding relation") {
143+
data.add("r31 v1 dV Tt=ag Mw10@");
144+
}
145+
SECTION("changing relation") {
146+
data.add("r32 v1 dV Tt=ag Mw10@,w15@");
147+
}
141148

142149
REQUIRE_NOTHROW(db.run_import(options, data()));
143150

@@ -202,7 +209,8 @@ TEST_CASE("test way: add relation with way in tboth stage 2 (marked)")
202209
"way_id = 10 AND rel_ids = '{31,32}'"));
203210
}
204211

205-
// adding relation (not marked)
212+
// adding relation (not marked), also check case where relation changed to
213+
// contain the way under test
206214

207215
TEST_CASE("test way: add relation with way in t1 (not marked)")
208216
{

0 commit comments

Comments
 (0)