forked from sionleroux/youmoved
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.rb
25 lines (22 loc) · 1022 Bytes
/
tests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'test/unit'
require_relative 'app'
# stub logger.info
def logger
Logger.new(STDERR)
end
class TestDistanceCalculator < Test::Unit::TestCase
def test_determining_movement_scale
assert_match(/^[0-9.]+ km$/, calculate_distance('1;1', '2;2'))
assert_match(/^[0-9]+ m$/, calculate_distance('1;1', '1.01;1.01'))
assert_equal("you've barely moved!", calculate_distance('1;1', '1.00001;1.00001'))
end
def test_significant_figures
assert_equal(2010.to_s + ' km', calculate_distance('1;1', '30;3'))
assert_equal(196.to_s + ' km', calculate_distance('1;1', '3;3'))
assert_equal(97.8.to_s + ' km', calculate_distance('1;1', '2;2'))
assert_equal(9.78.to_s + ' km', calculate_distance('1;1', '1.1;1.1'))
assert_equal(978.to_s + ' m', calculate_distance('1;1', '1.01;1.01'))
assert_equal(97.to_s + ' m', calculate_distance('1;1', '1.001;1.001'))
assert_equal(9.to_s + ' m', calculate_distance('1;1', '1.0001;1.0001'))
end
end