Add namespace around all files

This commit is contained in:
Patrick Niklaus
2016-01-05 16:51:13 +01:00
parent efc9007cbf
commit 6b18e4f7e9
194 changed files with 2648 additions and 1245 deletions
+4 -1
View File
@@ -10,9 +10,12 @@
BOOST_AUTO_TEST_SUITE(douglas_peucker)
using namespace osrm;
using namespace osrm::engine;
SegmentInformation getTestInfo(int lat, int lon, bool necessary)
{
return SegmentInformation(FixedPointCoordinate(lat, lon), 0, 0, 0, TurnInstruction::HeadOn,
return SegmentInformation(util::FixedPointCoordinate(lat, lon), 0, 0, 0, extractor::TurnInstruction::HeadOn,
necessary, false, 0);
}
+15 -8
View File
@@ -9,23 +9,28 @@
#include <cmath>
#include <vector>
BOOST_AUTO_TEST_CASE(geometry_string)
BOOST_AUTO_TEST_SUITE(polyline)
using namespace osrm;
using namespace osrm::engine;
BOOST_AUTO_TEST_CASE(decode)
{
// Polyline string for the 5 coordinates
const std::string polyline = "_gjaR_gjaR_pR_ibE_pR_ibE_pR_ibE_pR_ibE";
PolylineCompressor pc;
std::vector<FixedPointCoordinate> coords = pc.decode_string(polyline);
std::vector<util::FixedPointCoordinate> coords = pc.decode_string(polyline);
// Test coordinates; these would be the coordinates we give the loc parameter,
// e.g. loc=10.00,10.0&loc=10.01,10.1...
FixedPointCoordinate coord1(10.00 * COORDINATE_PRECISION, 10.0 * COORDINATE_PRECISION);
FixedPointCoordinate coord2(10.01 * COORDINATE_PRECISION, 10.1 * COORDINATE_PRECISION);
FixedPointCoordinate coord3(10.02 * COORDINATE_PRECISION, 10.2 * COORDINATE_PRECISION);
FixedPointCoordinate coord4(10.03 * COORDINATE_PRECISION, 10.3 * COORDINATE_PRECISION);
FixedPointCoordinate coord5(10.04 * COORDINATE_PRECISION, 10.4 * COORDINATE_PRECISION);
util::FixedPointCoordinate coord1(10.00 * COORDINATE_PRECISION, 10.0 * COORDINATE_PRECISION);
util::FixedPointCoordinate coord2(10.01 * COORDINATE_PRECISION, 10.1 * COORDINATE_PRECISION);
util::FixedPointCoordinate coord3(10.02 * COORDINATE_PRECISION, 10.2 * COORDINATE_PRECISION);
util::FixedPointCoordinate coord4(10.03 * COORDINATE_PRECISION, 10.3 * COORDINATE_PRECISION);
util::FixedPointCoordinate coord5(10.04 * COORDINATE_PRECISION, 10.4 * COORDINATE_PRECISION);
// Put the test coordinates into the vector for comparison
std::vector<FixedPointCoordinate> cmp_coords;
std::vector<util::FixedPointCoordinate> cmp_coords;
cmp_coords.emplace_back(coord1);
cmp_coords.emplace_back(coord2);
cmp_coords.emplace_back(coord3);
@@ -45,3 +50,5 @@ BOOST_AUTO_TEST_CASE(geometry_string)
BOOST_CHECK_CLOSE(cmp1_lon, cmp2_lon, 0.0001);
}
}
BOOST_AUTO_TEST_SUITE_END()
@@ -6,6 +6,9 @@
BOOST_AUTO_TEST_SUITE(compressed_edge_container)
using namespace osrm;
using namespace osrm::extractor;
BOOST_AUTO_TEST_CASE(long_road_test)
{
// 0 1 2 3
+10 -10
View File
@@ -12,6 +12,11 @@
BOOST_AUTO_TEST_SUITE(graph_compressor)
using namespace osrm;
using namespace osrm::extractor;
using InputEdge = util::NodeBasedDynamicGraph::InputEdge;
using Graph = util::NodeBasedDynamicGraph;
BOOST_AUTO_TEST_CASE(long_road_test)
{
//
@@ -25,7 +30,6 @@ BOOST_AUTO_TEST_CASE(long_road_test)
RestrictionMap map;
CompressedEdgeContainer container;
using InputEdge = NodeBasedDynamicGraph::InputEdge;
std::vector<InputEdge> edges = {
// source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout,
// travel_mode
@@ -42,7 +46,7 @@ BOOST_AUTO_TEST_CASE(long_road_test)
BOOST_ASSERT(edges[2].data.IsCompatibleTo(edges[4].data));
BOOST_ASSERT(edges[4].data.IsCompatibleTo(edges[6].data));
NodeBasedDynamicGraph graph(5, edges);
Graph graph(5, edges);
compressor.Compress(barrier_nodes, traffic_lights, map, graph, container);
BOOST_CHECK_EQUAL(graph.FindEdge(0, 1), SPECIAL_EDGEID);
@@ -67,7 +71,6 @@ BOOST_AUTO_TEST_CASE(loop_test)
RestrictionMap map;
CompressedEdgeContainer container;
using InputEdge = NodeBasedDynamicGraph::InputEdge;
std::vector<InputEdge> edges = {
// source, target, distance, edge_id, name_id, access_restricted, forward, backward,
// roundabout, travel_mode
@@ -98,7 +101,7 @@ BOOST_AUTO_TEST_CASE(loop_test)
BOOST_ASSERT(edges[9].data.IsCompatibleTo(edges[10].data));
BOOST_ASSERT(edges[10].data.IsCompatibleTo(edges[11].data));
NodeBasedDynamicGraph graph(6, edges);
Graph graph(6, edges);
compressor.Compress(barrier_nodes, traffic_lights, map, graph, container);
BOOST_CHECK_EQUAL(graph.FindEdge(5, 0), SPECIAL_EDGEID);
@@ -125,7 +128,6 @@ BOOST_AUTO_TEST_CASE(t_intersection)
RestrictionMap map;
CompressedEdgeContainer container;
using InputEdge = NodeBasedDynamicGraph::InputEdge;
std::vector<InputEdge> edges = {
// source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout,
// travel_mode
@@ -143,7 +145,7 @@ BOOST_AUTO_TEST_CASE(t_intersection)
BOOST_ASSERT(edges[3].data.IsCompatibleTo(edges[4].data));
BOOST_ASSERT(edges[4].data.IsCompatibleTo(edges[5].data));
NodeBasedDynamicGraph graph(4, edges);
Graph graph(4, edges);
compressor.Compress(barrier_nodes, traffic_lights, map, graph, container);
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
@@ -164,7 +166,6 @@ BOOST_AUTO_TEST_CASE(street_name_changes)
RestrictionMap map;
CompressedEdgeContainer container;
using InputEdge = NodeBasedDynamicGraph::InputEdge;
std::vector<InputEdge> edges = {
// source, target, distance, edge_id, name_id, access_restricted, forward, backward,
// roundabout, travel_mode
@@ -177,7 +178,7 @@ BOOST_AUTO_TEST_CASE(street_name_changes)
BOOST_ASSERT(edges[0].data.IsCompatibleTo(edges[1].data));
BOOST_ASSERT(edges[2].data.IsCompatibleTo(edges[3].data));
NodeBasedDynamicGraph graph(5, edges);
Graph graph(5, edges);
compressor.Compress(barrier_nodes, traffic_lights, map, graph, container);
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
@@ -197,7 +198,6 @@ BOOST_AUTO_TEST_CASE(direction_changes)
RestrictionMap map;
CompressedEdgeContainer container;
using InputEdge = NodeBasedDynamicGraph::InputEdge;
std::vector<InputEdge> edges = {
// source, target, distance, edge_id, name_id, access_restricted, reverse, roundabout,
// travel_mode
@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(direction_changes)
{2, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT},
};
NodeBasedDynamicGraph graph(5, edges);
Graph graph(5, edges);
compressor.Compress(barrier_nodes, traffic_lights, map, graph, container);
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
+5 -2
View File
@@ -9,6 +9,9 @@
BOOST_AUTO_TEST_SUITE(raster_source)
using namespace osrm;
using namespace osrm::extractor;
int normalize(double coord) { return static_cast<int>(coord * COORDINATE_PRECISION); }
#define CHECK_QUERY(source_id, lon, lat, expected) \
@@ -73,11 +76,11 @@ BOOST_AUTO_TEST_CASE(raster_test)
BOOST_CHECK_EQUAL(source_already_loaded_id, 0);
BOOST_CHECK_THROW(sources.getRasterDataFromSource(1, normalize(0.02), normalize(0.02)),
osrm::exception);
util::exception);
BOOST_CHECK_THROW(
sources.loadRasterSource("../unit_tests/fixtures/nonexistent.asc", 0, 0.1, 0, 0.1, 7, 7),
osrm::exception);
util::exception);
}
BOOST_AUTO_TEST_SUITE_END()
+4 -1
View File
@@ -5,7 +5,10 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/test_case_template.hpp>
BOOST_AUTO_TEST_SUITE(bearing)
BOOST_AUTO_TEST_SUITE(bearing_test)
using namespace osrm;
using namespace osrm::util;
// Verify that the bearing-bounds checking function behaves as expected
BOOST_AUTO_TEST_CASE(bearing_range_test)
+3
View File
@@ -12,6 +12,9 @@
BOOST_AUTO_TEST_SUITE(binary_heap)
using namespace osrm;
using namespace osrm::util;
struct TestData
{
unsigned value;
+3
View File
@@ -6,6 +6,9 @@
#include <cmath>
using namespace osrm;
using namespace osrm::util;
// Regression test for bug captured in #1347
BOOST_AUTO_TEST_CASE(regression_test_1347)
{
+18 -15
View File
@@ -5,33 +5,36 @@
BOOST_AUTO_TEST_SUITE(durations_are_valid)
using namespace osrm;
using namespace osrm::util;
BOOST_AUTO_TEST_CASE(all_necessary_test)
{
BOOST_CHECK_EQUAL(durationIsValid("00:01"), true);
BOOST_CHECK_EQUAL(durationIsValid("00:01:01"), true);
BOOST_CHECK_EQUAL(durationIsValid("PT15M"), true);
BOOST_CHECK_EQUAL(extractor::durationIsValid("00:01"), true);
BOOST_CHECK_EQUAL(extractor::durationIsValid("00:01:01"), true);
BOOST_CHECK_EQUAL(extractor::durationIsValid("PT15M"), true);
}
BOOST_AUTO_TEST_CASE(common_durations_get_translated)
{
BOOST_CHECK_EQUAL(parseDuration("00:01"), 60);
BOOST_CHECK_EQUAL(parseDuration("00:01:01"), 61);
BOOST_CHECK_EQUAL(parseDuration("01:01"), 3660);
BOOST_CHECK_EQUAL(extractor::parseDuration("00:01"), 60);
BOOST_CHECK_EQUAL(extractor::parseDuration("00:01:01"), 61);
BOOST_CHECK_EQUAL(extractor::parseDuration("01:01"), 3660);
// check all combinations of iso duration tokens
BOOST_CHECK_EQUAL(parseDuration("PT1M1S"), 61);
BOOST_CHECK_EQUAL(parseDuration("PT1H1S"), 3601);
BOOST_CHECK_EQUAL(parseDuration("PT15M"), 900);
BOOST_CHECK_EQUAL(parseDuration("PT15S"), 15);
BOOST_CHECK_EQUAL(parseDuration("PT15H"), 54000);
BOOST_CHECK_EQUAL(parseDuration("PT1H15M"), 4500);
BOOST_CHECK_EQUAL(parseDuration("PT1H15M1S"), 4501);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT1M1S"), 61);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT1H1S"), 3601);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT15M"), 900);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT15S"), 15);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT15H"), 54000);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT1H15M"), 4500);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT1H15M1S"), 4501);
}
BOOST_AUTO_TEST_CASE(iso_8601_durations_case_insensitive)
{
BOOST_CHECK_EQUAL(parseDuration("PT15m"), 900);
BOOST_CHECK_EQUAL(parseDuration("PT1h15m"), 4500);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT15m"), 900);
BOOST_CHECK_EQUAL(extractor::parseDuration("PT1h15m"), 4500);
}
BOOST_AUTO_TEST_SUITE_END()
+3
View File
@@ -8,6 +8,9 @@
BOOST_AUTO_TEST_SUITE(dynamic_graph)
using namespace osrm;
using namespace osrm::util;
struct TestData
{
EdgeID id;
+5 -2
View File
@@ -7,11 +7,14 @@
#include <numeric>
#include <stxxl/vector>
BOOST_AUTO_TEST_SUITE(range_table)
using namespace osrm;
using namespace osrm::util;
constexpr unsigned BLOCK_SIZE = 16;
typedef RangeTable<BLOCK_SIZE, false> TestRangeTable;
BOOST_AUTO_TEST_SUITE(range_table)
void ConstructionTest(stxxl::vector<unsigned> lengths, std::vector<unsigned> offsets)
{
BOOST_ASSERT(lengths.size() == offsets.size() - 1);
+3
View File
@@ -10,6 +10,9 @@
BOOST_AUTO_TEST_SUITE(static_graph)
using namespace osrm;
using namespace osrm::util;
struct TestData
{
EdgeID id;
+10 -7
View File
@@ -25,10 +25,13 @@
BOOST_AUTO_TEST_SUITE(static_rtree)
using namespace osrm;
using namespace osrm::util;
constexpr uint32_t TEST_BRANCHING_FACTOR = 8;
constexpr uint32_t TEST_LEAF_NODE_SIZE = 64;
typedef EdgeBasedNode TestData;
using TestData = extractor::EdgeBasedNode;
using TestStaticRTree = StaticRTree<TestData,
std::vector<FixedPointCoordinate>,
false,
@@ -108,7 +111,7 @@ template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture
{
int lat = lat_udist(g);
int lon = lon_udist(g);
nodes.emplace_back(QueryNode(lat, lon, OSMNodeID(i)));
nodes.emplace_back(extractor::QueryNode(lat, lon, OSMNodeID(i)));
coords->emplace_back(FixedPointCoordinate(lat, lon));
}
@@ -131,7 +134,7 @@ template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture
}
}
std::vector<QueryNode> nodes;
std::vector<extractor::QueryNode> nodes;
std::shared_ptr<std::vector<FixedPointCoordinate>> coords;
std::vector<TestData> edges;
};
@@ -148,7 +151,7 @@ struct GraphFixture
FixedPointCoordinate c(input_coords[i].first * COORDINATE_PRECISION,
input_coords[i].second * COORDINATE_PRECISION);
coords->emplace_back(c);
nodes.emplace_back(QueryNode(c.lat, c.lon, OSMNodeID(i)));
nodes.emplace_back(extractor::QueryNode(c.lat, c.lon, OSMNodeID(i)));
}
for (const auto &pair : input_edges)
@@ -166,7 +169,7 @@ struct GraphFixture
}
}
std::vector<QueryNode> nodes;
std::vector<extractor::QueryNode> nodes;
std::shared_ptr<std::vector<FixedPointCoordinate>> coords;
std::vector<TestData> edges;
};
@@ -252,7 +255,7 @@ void build_rtree(const std::string &prefix,
boost::filesystem::ofstream node_stream(coords_path, std::ios::binary);
const auto num_nodes = static_cast<unsigned>(fixture->nodes.size());
node_stream.write((char *)&num_nodes, sizeof(unsigned));
node_stream.write((char *)&(fixture->nodes[0]), num_nodes * sizeof(QueryNode));
node_stream.write((char *)&(fixture->nodes[0]), num_nodes * sizeof(extractor::QueryNode));
node_stream.close();
RTreeT r(fixture->edges, nodes_path, leaves_path, fixture->nodes);
@@ -408,7 +411,7 @@ BOOST_AUTO_TEST_CASE(bearing_tests)
std::string nodes_path;
build_rtree<GraphFixture, MiniStaticRTree>("test_bearing", &fixture, leaves_path, nodes_path);
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
GeospatialQuery<MiniStaticRTree> query(rtree, fixture.coords);
engine::GeospatialQuery<MiniStaticRTree> query(rtree, fixture.coords);
FixedPointCoordinate input(5.0 * COORDINATE_PRECISION, 5.1 * COORDINATE_PRECISION);
+3
View File
@@ -7,6 +7,9 @@
BOOST_AUTO_TEST_SUITE(string_util)
using namespace osrm;
using namespace osrm::util;
BOOST_AUTO_TEST_CASE(json_escaping)
{
std::string input{"\b\\"};