Skip to content

Commit 7d9f51c

Browse files
authored
Merge pull request #1366 from joto/testing-namespaces
Cleanup testing namespaces
2 parents b27e80c + 2c3992a commit 7d9f51c

14 files changed

+59
-54
lines changed

tests/common-import.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ inline void parse_file(options_t const &options,
5151
}
5252
}
5353

54+
namespace db {
55+
5456
/**
5557
* This is used as a helper to assemble OSM objects into an OPL file which
5658
* can later be used as input for testing.
@@ -114,8 +116,6 @@ class data_t
114116
std::string m_result;
115117
};
116118

117-
namespace db {
118-
119119
/**
120120
* Convenience class around tempdb_t that offers functions for
121121
* data import from file and strings.
@@ -216,12 +216,12 @@ class import_t
216216
{out_test}, file);
217217
}
218218

219-
pg::conn_t connect() { return m_db.connect(); }
219+
testing::pg::conn_t connect() { return m_db.connect(); }
220220

221-
pg::tempdb_t const &db() const { return m_db; }
221+
testing::pg::tempdb_t const &db() const { return m_db; }
222222

223223
private:
224-
pg::tempdb_t m_db;
224+
testing::pg::tempdb_t m_db;
225225
};
226226

227227
} // namespace db

tests/common-options.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class opt_t
2828
return *this;
2929
}
3030

31-
opt_t &slim(pg::tempdb_t const &db)
31+
opt_t &slim(testing::pg::tempdb_t const &db)
3232
{
3333
m_opt.slim = true;
3434
m_opt.database_options = db.db_options();

tests/common-pg.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define getpid _getpid
2020
#endif
2121

22+
namespace testing {
2223
/// Helper classes for postgres connections
2324
namespace pg {
2425

@@ -141,5 +142,6 @@ class tempdb_t
141142
};
142143

143144
} // namespace pg
145+
} // namespace testing
144146

145147
#endif // OSM2PGSQL_TEST_COMMON_PG_HPP

tests/test-db-copy-mgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "common-pg.hpp"
88
#include "db-copy-mgr.hpp"
99

10-
static pg::tempdb_t db;
10+
static testing::pg::tempdb_t db;
1111

1212
using copy_mgr_t = db_copy_mgr_t<db_deleter_by_id_t>;
1313

tests/test-db-copy-thread.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#include "db-copy.hpp"
55
#include "gazetteer-style.hpp"
66

7-
static pg::tempdb_t db;
7+
static testing::pg::tempdb_t db;
88

9-
static int table_count(pg::conn_t const &conn, std::string const &where = "")
9+
static int table_count(testing::pg::conn_t const &conn,
10+
std::string const &where = "")
1011
{
1112
return conn.require_scalar<int>("SELECT count(*) FROM test_copy_thread " +
1213
where);

tests/test-middle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <algorithm>
1515

16-
static pg::tempdb_t db;
16+
static testing::pg::tempdb_t db;
1717

1818
namespace {
1919

@@ -106,15 +106,15 @@ void expect_location(osmium::Location loc, osmium::Node const &expected)
106106

107107
struct options_slim_default
108108
{
109-
static options_t options(pg::tempdb_t const &tmpdb)
109+
static options_t options(testing::pg::tempdb_t const &tmpdb)
110110
{
111111
return testing::opt_t().slim(tmpdb);
112112
}
113113
};
114114

115115
struct options_slim_with_schema
116116
{
117-
static options_t options(pg::tempdb_t const &tmpdb)
117+
static options_t options(testing::pg::tempdb_t const &tmpdb)
118118
{
119119
options_t o = testing::opt_t().slim(tmpdb);
120120
o.middle_dbschema = "osm";
@@ -124,7 +124,7 @@ struct options_slim_with_schema
124124

125125
struct options_slim_dense_cache
126126
{
127-
static options_t options(pg::tempdb_t const &tmpdb)
127+
static options_t options(testing::pg::tempdb_t const &tmpdb)
128128
{
129129
options_t o = options_slim_default::options(tmpdb);
130130
o.alloc_chunkwise = ALLOC_DENSE;
@@ -134,15 +134,15 @@ struct options_slim_dense_cache
134134

135135
struct options_flat_node_cache
136136
{
137-
static options_t options(pg::tempdb_t const &tmpdb)
137+
static options_t options(testing::pg::tempdb_t const &tmpdb)
138138
{
139139
return testing::opt_t().slim(tmpdb).flatnodes();
140140
}
141141
};
142142

143143
struct options_ram_optimized
144144
{
145-
static options_t options(pg::tempdb_t const &)
145+
static options_t options(testing::pg::tempdb_t const &)
146146
{
147147
options_t o = testing::opt_t();
148148
o.alloc_chunkwise = ALLOC_SPARSE | ALLOC_DENSE;
@@ -152,7 +152,7 @@ struct options_ram_optimized
152152

153153
struct options_ram_flatnode
154154
{
155-
static options_t options(pg::tempdb_t const &)
155+
static options_t options(testing::pg::tempdb_t const &)
156156
{
157157
options_t o = testing::opt_t().flatnodes();
158158
o.alloc_chunkwise = ALLOC_SPARSE | ALLOC_DENSE;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST_CASE("add way")
2828
{
2929
options_t options = testing::opt_t().slim().flex(conf_file);
3030

31-
testing::data_t data{tdata};
31+
testing::db::data_t data{tdata};
3232

3333
REQUIRE_NOTHROW(db.run_import(options, data()));
3434

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TEST_CASE("change way from t1")
2020
{
2121
options_t options = testing::opt_t().slim().flex(conf_file);
2222

23-
testing::data_t data{tdata};
23+
testing::db::data_t data{tdata};
2424
data.add({"w10 v1 dV Tt1=yes Nn10,n11",
2525
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
2626

@@ -63,7 +63,7 @@ TEST_CASE("change way from t2")
6363
{
6464
options_t options = testing::opt_t().slim().flex(conf_file);
6565

66-
testing::data_t data{tdata};
66+
testing::db::data_t data{tdata};
6767
data.add({"w10 v1 dV Tt2=yes Nn10,n11",
6868
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
6969

@@ -106,7 +106,7 @@ TEST_CASE("change way from t1 and t2")
106106
{
107107
options_t options = testing::opt_t().slim().flex(conf_file);
108108

109-
testing::data_t data{tdata};
109+
testing::db::data_t data{tdata};
110110
data.add({"w10 v1 dV Tt1=yes,t2=yes Nn10,n11",
111111
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
112112

@@ -149,7 +149,7 @@ TEST_CASE("change valid geom to invalid geom")
149149
{
150150
options_t options = testing::opt_t().slim().flex(conf_file);
151151

152-
testing::data_t data{tdata};
152+
testing::db::data_t data{tdata};
153153
data.add({"w10 v1 dV Tt1=yes,t2=yes,tboth=yes Nn10,n11",
154154
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
155155

@@ -189,7 +189,7 @@ TEST_CASE("change invalid geom to valid geom")
189189
{
190190
options_t options = testing::opt_t().slim().flex(conf_file);
191191

192-
testing::data_t data{tdata};
192+
testing::db::data_t data{tdata};
193193
data.add({"w10 v1 dV Tt1=yes,t2=yes,tboth=yes Nn10",
194194
"r30 v1 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark"});
195195

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TEST_CASE("delete way: not a member")
2020
{
2121
options_t options = testing::opt_t().slim().flex(conf_file);
2222

23-
testing::data_t data{tdata};
23+
testing::db::data_t data{tdata};
2424

2525
unsigned long num_t1 = 0;
2626
unsigned long num_tboth = 0;
@@ -58,7 +58,7 @@ TEST_CASE("delete way: relation member")
5858
{
5959
options_t options = testing::opt_t().slim().flex(conf_file);
6060

61-
testing::data_t data{tdata};
61+
testing::db::data_t data{tdata};
6262

6363
unsigned long num_t1 = 0;
6464
unsigned long num_t2 = 0;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST_CASE("test way: add relation with way in t1 (marked)")
3232
{
3333
options_t options = testing::opt_t().slim().flex(conf_file);
3434

35-
testing::data_t data{tdata};
35+
testing::db::data_t data{tdata};
3636

3737
data.add("w10 v1 dV Tt1=yes,t2=yes Nn10,n11");
3838

@@ -72,7 +72,7 @@ TEST_CASE("test way: add relation with way in t2 (marked)")
7272
{
7373
options_t options = testing::opt_t().slim().flex(conf_file);
7474

75-
testing::data_t data{tdata};
75+
testing::db::data_t data{tdata};
7676

7777
data.add("w10 v1 dV Tt2=yes Nn10,n11");
7878
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");
@@ -107,7 +107,7 @@ TEST_CASE("test way: add relation with way in t1 and t2 (marked)")
107107
{
108108
options_t options = testing::opt_t().slim().flex(conf_file);
109109

110-
testing::data_t data{tdata};
110+
testing::db::data_t data{tdata};
111111

112112
data.add("w10 v1 dV Tt1=yes,t2=yes Nn10,n11");
113113
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");
@@ -142,7 +142,7 @@ TEST_CASE("test way: add (to) relation with way in tboth stage 1 (marked)")
142142
{
143143
options_t options = testing::opt_t().slim().flex(conf_file);
144144

145-
testing::data_t data{tdata};
145+
testing::db::data_t data{tdata};
146146

147147
data.add("w10 v1 dV Ttboth=yes Nn10,n11");
148148

@@ -188,7 +188,7 @@ TEST_CASE("test way: add relation with way in tboth stage 2 (marked)")
188188
{
189189
options_t options = testing::opt_t().slim().flex(conf_file);
190190

191-
testing::data_t data{tdata};
191+
testing::db::data_t data{tdata};
192192

193193
data.add("w10 v1 dV Ttboth=yes Nn10,n11");
194194
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");
@@ -228,7 +228,7 @@ TEST_CASE("test way: add relation with way in t1 (not marked)")
228228
{
229229
options_t options = testing::opt_t().slim().flex(conf_file);
230230

231-
testing::data_t data{tdata};
231+
testing::db::data_t data{tdata};
232232

233233
data.add("w10 v1 dV Tt1=yes,t2=yes Nn10,n11");
234234

@@ -267,7 +267,7 @@ TEST_CASE("test way: add relation with way in t2 (not marked)")
267267
{
268268
options_t options = testing::opt_t().slim().flex(conf_file);
269269

270-
testing::data_t data{tdata};
270+
testing::db::data_t data{tdata};
271271

272272
data.add("w10 v1 dV Tt2=yes Nn10,n11");
273273
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");
@@ -302,7 +302,7 @@ TEST_CASE("test way: add relation with way in t1 and t2 (not marked)")
302302
{
303303
options_t options = testing::opt_t().slim().flex(conf_file);
304304

305-
testing::data_t data{tdata};
305+
testing::db::data_t data{tdata};
306306

307307
data.add("w10 v1 dV Tt1=yes,t2=yes Nn10,n11");
308308
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");
@@ -337,7 +337,7 @@ TEST_CASE("test way: add relation with way in tboth stage 1 (not marked)")
337337
{
338338
options_t options = testing::opt_t().slim().flex(conf_file);
339339

340-
testing::data_t data{tdata};
340+
testing::db::data_t data{tdata};
341341

342342
data.add("w10 v1 dV Ttboth=yes Nn10,n11");
343343
data.add("r31 v1 dV Tt=ag Mw10@,w11@,w12@,w13@,w14@");
@@ -374,7 +374,7 @@ TEST_CASE("test way: add relation with way in tboth stage 2 (not marked)")
374374
{
375375
options_t options = testing::opt_t().slim().flex(conf_file);
376376

377-
testing::data_t data{tdata};
377+
testing::db::data_t data{tdata};
378378

379379
data.add("w10 v1 dV Ttboth=yes Nn10,n11");
380380
data.add("r31 v1 dV Tt=ag Mw10@mark,w11@,w12@,w13@,w14@");

0 commit comments

Comments
 (0)