Merge pull request #393 from emiltin/cuke_ranges
add fuzzy range options to cucumber tests
This commit is contained in:
commit
d26d3bb574
@ -145,6 +145,23 @@ Feature: Distance calculation
|
|||||||
| x | w | xw | 3610 |
|
| x | w | xw | 3610 |
|
||||||
| x | y | xy | 3160 |
|
| x | y | xy | 3160 |
|
||||||
|
|
||||||
|
Scenario: 1-10m distances
|
||||||
|
Given a grid size of 2 meters
|
||||||
|
Given the node map
|
||||||
|
| a | b | c | d | e | f |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| abcdee |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route | distance |
|
||||||
|
| a | b | abcedf | 2 |
|
||||||
|
| a | c | abcedf | 4 |
|
||||||
|
| a | d | abcedf | 6 |
|
||||||
|
| a | e | abcedf | 8 |
|
||||||
|
| a | f | abcedf | 10 |
|
||||||
|
|
||||||
Scenario: 1m distances
|
Scenario: 1m distances
|
||||||
Given a grid size of 1 meters
|
Given a grid size of 1 meters
|
||||||
Given the node map
|
Given the node map
|
||||||
@ -214,12 +231,12 @@ Feature: Distance calculation
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | distance |
|
| from | to | route | distance |
|
||||||
| a | b | abc | 1000 |
|
| a | b | abc | 1000 ~0.01% |
|
||||||
| b | a | abc | 1000 |
|
| b | a | abc | 1000 ~0.01% |
|
||||||
| b | c | abc | 1000 |
|
| b | c | abc | 1000 ~0.01% |
|
||||||
| c | b | abc | 1000 |
|
| c | b | abc | 1000 ~0.01% |
|
||||||
| a | c | abc | 2000 |
|
| a | c | abc | 2000 ~0.01% |
|
||||||
| c | a | abc | 2000 |
|
| c | a | abc | 2000 ~0.01% |
|
||||||
|
|
||||||
Scenario: 10km distances
|
Scenario: 10km distances
|
||||||
Given a grid size of 10000 meters
|
Given a grid size of 10000 meters
|
||||||
@ -233,12 +250,12 @@ Feature: Distance calculation
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | distance |
|
| from | to | route | distance |
|
||||||
| a | b | abc | 10000 |
|
| a | b | abc | 10000 ~0.01% |
|
||||||
| b | a | abc | 10000 |
|
| b | a | abc | 10000 ~0.01% |
|
||||||
| b | c | abc | 10000 |
|
| b | c | abc | 10000 ~0.01% |
|
||||||
| c | b | abc | 10000 |
|
| c | b | abc | 10000 ~0.01% |
|
||||||
| a | c | abc | 20000 |
|
| a | c | abc | 20000 ~0.01% |
|
||||||
| c | a | abc | 20000 |
|
| c | a | abc | 20000 ~0.01% |
|
||||||
|
|
||||||
Scenario: 100km distances
|
Scenario: 100km distances
|
||||||
Given a grid size of 100000 meters
|
Given a grid size of 100000 meters
|
||||||
@ -252,31 +269,12 @@ Feature: Distance calculation
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | distance |
|
| from | to | route | distance |
|
||||||
| a | b | abc | 100000 |
|
| a | b | abc | 100000 ~0.01% |
|
||||||
| b | a | abc | 100000 |
|
| b | a | abc | 100000 ~0.01% |
|
||||||
| b | c | abc | 100000 |
|
| b | c | abc | 100000 ~0.01% |
|
||||||
| c | b | abc | 100000 |
|
| c | b | abc | 100000 ~0.01% |
|
||||||
| a | c | abc | 200000 |
|
| a | c | abc | 200000 ~0.01% |
|
||||||
| c | a | abc | 200000 |
|
| c | a | abc | 200000 ~0.01% |
|
||||||
|
|
||||||
Scenario: 1000km distances
|
|
||||||
Given a grid size of 1000000 meters
|
|
||||||
Given the node map
|
|
||||||
| a | b |
|
|
||||||
| | c |
|
|
||||||
|
|
||||||
And the ways
|
|
||||||
| nodes |
|
|
||||||
| abc |
|
|
||||||
|
|
||||||
When I route I should get
|
|
||||||
| from | to | route | distance |
|
|
||||||
| a | b | abc | 1000000 |
|
|
||||||
| b | a | abc | 1000000 |
|
|
||||||
| b | c | abc | 1000000 |
|
|
||||||
| c | b | abc | 1000000 |
|
|
||||||
| a | c | abc | 2000000 |
|
|
||||||
| c | a | abc | 2000000 |
|
|
||||||
|
|
||||||
Scenario: Angles at 1000km scale
|
Scenario: Angles at 1000km scale
|
||||||
Given a grid size of 1000 meters
|
Given a grid size of 1000 meters
|
||||||
|
@ -231,7 +231,32 @@ When /^I route I should get$/ do |table|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if row != got
|
ok = true
|
||||||
|
row.keys.each do |key|
|
||||||
|
if row[key].match /(.*)\s+~(.+)%$/
|
||||||
|
margin = 1 - $2.to_f*0.01
|
||||||
|
from = $1.to_f*margin
|
||||||
|
to = $1.to_f/margin
|
||||||
|
if (from..to).cover? got[key].to_f
|
||||||
|
got[key] = row[key]
|
||||||
|
else
|
||||||
|
ok = false
|
||||||
|
end
|
||||||
|
elsif row[key].match /(.*)\s+\+\-(.+)$/
|
||||||
|
margin = $2.to_f
|
||||||
|
from = $1.to_f-margin
|
||||||
|
to = $1.to_f+margin
|
||||||
|
if (from..to).cover? got[key].to_f
|
||||||
|
got[key] = row[key]
|
||||||
|
else
|
||||||
|
ok = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ok = row[key] == got[key].to_f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless ok
|
||||||
failed = { :attempt => 'route', :query => @query, :response => response }
|
failed = { :attempt => 'route', :query => @query, :response => response }
|
||||||
log_fail row,got,[failed]
|
log_fail row,got,[failed]
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user