Skip to content

Commit 0b6f4c2

Browse files
committed
tests: clean up use of random device
Use a fixed seed to make the results reproducable. Choose a distribution range that ensures that all points are valid latitudes/longitudes.
1 parent 7905ebf commit 0b6f4c2

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/test-output-gazetteer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
static testing::db::import_t db;
99

10-
static std::random_device dev;
11-
static std::mt19937 rng(dev());
10+
// Use a random device with a fixed seed. We don't really care about
11+
// the quality of random numbers here, we just need to generate valid
12+
// OSM test data. The fixed seed ensures that the results are reproducible.
13+
static std::mt19937_64 rng(47382);
1214

1315
class node_opl_t
1416
{
@@ -72,7 +74,7 @@ class way_opl_t
7274
unsigned const num_nodes = intdist(rng);
7375

7476
// compute the start point, all points afterwards are relative
75-
std::uniform_real_distribution<double> dist{-90, 89.99};
77+
std::uniform_real_distribution<double> dist{-89.9, 89.9};
7678
double x = 2 * dist(rng);
7779
double y = dist(rng);
7880

@@ -138,7 +140,7 @@ class relation_opl_t
138140
osmid_t make_nodes()
139141
{
140142
// compute a centre points and compute four corners from this
141-
std::uniform_real_distribution<double> dist{-90, 89.99};
143+
std::uniform_real_distribution<double> dist{-89.9, 89.9};
142144
double const x = 2 * dist(rng);
143145
double const y = dist(rng);
144146

0 commit comments

Comments
 (0)