cuke: test travel time of individual instructions
This commit is contained in:
parent
165c252fc8
commit
df83dfdfe8
@ -46,6 +46,8 @@ When /^I route I should get$/ do |table|
|
||||
compasses = compass_list json['route_instructions']
|
||||
turns = turn_list json['route_instructions']
|
||||
modes = mode_list json['route_instructions']
|
||||
times = time_list json['route_instructions']
|
||||
distances = distance_list json['route_instructions']
|
||||
end
|
||||
end
|
||||
|
||||
@ -90,6 +92,12 @@ When /^I route I should get$/ do |table|
|
||||
if table.headers.include? 'modes'
|
||||
got['modes'] = modes
|
||||
end
|
||||
if table.headers.include? 'times'
|
||||
got['times'] = times
|
||||
end
|
||||
if table.headers.include? 'distances'
|
||||
got['distances'] = distances
|
||||
end
|
||||
if table.headers.include? '#' # comment column
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
|
@ -80,25 +80,23 @@ def route_status response
|
||||
end
|
||||
end
|
||||
|
||||
def way_list instructions
|
||||
def extract_instruction_list instructions, index, postfix=nil
|
||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
||||
map { |r| r[1] }.
|
||||
map { |r| r=="" ? '""' : r }.
|
||||
map { |r| r[index] }.
|
||||
map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }.
|
||||
join(',')
|
||||
end
|
||||
|
||||
def way_list instructions
|
||||
extract_instruction_list instructions, 1
|
||||
end
|
||||
|
||||
def compass_list instructions
|
||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
||||
map { |r| r[6] }.
|
||||
map { |r| r=="" ? '""' : r }.
|
||||
join(',')
|
||||
extract_instruction_list instructions, 6
|
||||
end
|
||||
|
||||
def bearing_list instructions
|
||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
||||
map { |r| r[7] }.
|
||||
map { |r| r=="" ? '""' : r }.
|
||||
join(',')
|
||||
extract_instruction_list instructions, 7
|
||||
end
|
||||
|
||||
def turn_list instructions
|
||||
@ -125,15 +123,20 @@ def turn_list instructions
|
||||
# replace instructions codes with strings
|
||||
# "11-3" (enter roundabout and leave a 3rd exit) gets converted to "enter_roundabout-3"
|
||||
instructions.map do |r|
|
||||
r[0].to_s.gsub!(/^\d*/) do |match|
|
||||
r[0].to_s.gsub(/^\d*/) do |match|
|
||||
types[match.to_i].to_s
|
||||
end
|
||||
end.join(',')
|
||||
end
|
||||
|
||||
def mode_list instructions
|
||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
||||
map { |r| r[8] }.
|
||||
map { |r| (r=="" || r==nil) ? '""' : r }.
|
||||
join(',')
|
||||
extract_instruction_list instructions, 8
|
||||
end
|
||||
|
||||
def time_list instructions
|
||||
extract_instruction_list instructions, 4, "s"
|
||||
end
|
||||
|
||||
def distance_list instructions
|
||||
extract_instruction_list instructions, 2, "m"
|
||||
end
|
@ -213,3 +213,26 @@ Feature: Estimation of travel time
|
||||
| 4 | 3 | ab | 10s +-1 |
|
||||
| 4 | 2 | ab | 20s +-1 |
|
||||
| 4 | 1 | ab | 30s +-1 |
|
||||
|
||||
@bug
|
||||
Scenario: Total travel time should match sum of times of individual ways
|
||||
Given a grid size of 1000 meters
|
||||
And the node map
|
||||
| a | b | | | |
|
||||
| | | | | |
|
||||
| | c | | | d |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| ab | primary |
|
||||
| bc | primary |
|
||||
| cd | primary |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | distances | distance | times | time |
|
||||
| a | b | ab | 1000m +-1 | 1000m +-1 | 100s +-1 | 100s +-1 |
|
||||
| b | c | bc | 2000m +-1 | 2000m +-1 | 200s +-1 | 200s +-1 |
|
||||
| c | d | cd | 3000m +-1 | 3000m +-1 | 300s +-1 | 300s +-1 |
|
||||
| a | c | ab,bc | 1000m,2000m +-1 | 3000m +-1 | 100s,200s +-1 | 300s +-1 |
|
||||
| b | d | bc,cd | 2000m,3000m +-1 | 5000m +-1 | 200s,300s +-1 | 500s +-1 |
|
||||
| a | d | ab,bc,cd | 1000m,2000m,3000m +-1 | 6000m +-1 | 100s,200s,300s +-1 | 600s +-1 |
|
||||
|
Loading…
Reference in New Issue
Block a user