Skip to content

Commit

Permalink
Merge pull request #49 from tedsteiner/test
Browse files Browse the repository at this point in the history
Fix routing test, improve test coverage
  • Loading branch information
garborg committed Oct 10, 2014
2 parents 784db2a + 899450a commit 84eac32
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test/coordinates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ bounds_enu = lla2enu(bounds)
@test_approx_eq bounds_enu.min_x -247.1091823451915
@test_approx_eq bounds_enu.max_x 247.1268196141778

@test_throws ArgumentError OpenStreetMap.Bounds(-90.1, 90.1, -181.1, 181.1)

end # module TestCoordinates
24 changes: 20 additions & 4 deletions test/routes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,27 @@ node0 = nearestNode(nodesENU, loc_start, collect(keys(segment_network.v)))
node1 = nearestNode(nodesENU, loc_end, collect(keys(segment_network.v)))

# Shortest route
_, shortest_segment_distance = shortestRoute(network, node0, node1)
@test shortest_segment_distance == shortest_distance
_, shortest_segment_distance = shortestRoute(segment_network, node0, node1)
@test_approx_eq shortest_segment_distance shortest_distance

# Fastest route
_, fastest_segment_time = fastestRoute(network, node0, node1)
@test fastest_segment_time == fastest_time
_, fastest_segment_time = fastestRoute(segment_network, node0, node1)
@test_approx_eq fastest_segment_time fastest_time

# Form transportation networks with directions reversed
r_network = createGraph(nodesENU, hwys, roads, Set(1:8), true)
r_segment_network = createGraph(segments, intersections, true)

# Reverse routes over reversed network
_, r_shortest_distance = shortestRoute(r_network, node1, node0)
_, r_fastest_time = fastestRoute(r_network, node1, node0)
@test_approx_eq r_shortest_distance shortest_distance
@test_approx_eq r_fastest_time fastest_time

# Reverse routes over reversed segment network
_, r_shortest_segment_distance = shortestRoute(r_segment_network, node1, node0)
_, r_fastest_segment_time = fastestRoute(r_segment_network, node1, node0)
@test_approx_eq r_shortest_segment_distance shortest_distance
@test_approx_eq r_fastest_segment_time fastest_time

end # module TestRoutes

0 comments on commit 84eac32

Please sign in to comment.