-
Notifications
You must be signed in to change notification settings - Fork 0
/
day_1_tests.rb
39 lines (29 loc) · 1.01 KB
/
day_1_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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'minitest/autorun'
require './day_1'
class Day1Test < Minitest::Test
def test_next_direction_determination
assert_equal 3, next_direction(0,"L")
assert_equal 1, next_direction(0,"R")
assert_equal 2, next_direction(3,"L")
assert_equal 0, next_direction(3,"R")
end
def test_next_position
current_position = Position.new(0,0)
expected_position = Position.new(-4,0)
assert_equal expected_position, next_position(current_position,3,4)
end
def test_find_destination
instructions = ["L10", "R10", "R10", "L5"]
expected_destination = Position.new(0,15)
assert_equal expected_destination, find_destination(instructions)
end
def test_calculate_distance_from_origin
position = Position.new(-15,3)
assert_equal 18, position.distance_from_origin
end
def test_find_previously_visited
instructions = ["R8", "R4", "R4", "R8"]
expected_destination = Position.new(4,0)
assert_equal expected_destination, find_previously_visited(instructions)
end
end