-
Notifications
You must be signed in to change notification settings - Fork 0
/
day_2_tests.rb
48 lines (41 loc) · 1.28 KB
/
day_2_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
40
41
42
43
44
45
46
47
48
require 'minitest/autorun'
require './day_2'
class Day2Test < Minitest::Test
def test_determine_next_position
test_cases = [
{
instructions: "ULL",
starting_position: Position.new(1,1),
expected_next_position: Position.new(0,0)
},
{
instructions: "RRDDD",
starting_position: Position.new(0,0),
expected_next_position: Position.new(2,2)
},
{
instructions: "LURDL",
starting_position: Position.new(2,2),
expected_next_position: Position.new(1,2)
},
{
instructions: "UUUUD",
starting_position: Position.new(1,2),
expected_next_position: Position.new(1,1)
}
]
test_cases.each do |test_case|
result = determine_next_position(test_case[:starting_position], test_case[:instructions])
assert_equal test_case[:expected_next_position], result
end
end
def test_determine_passcode
instructions = %w(ULL RRDDD LURDL UUUUD)
assert_equal "1985", determine_passcode(instructions)
end
def test_diamond_keypad
instructions = %w(ULL RRDDD LURDL UUUUD)
starting_position = Position.new(0, 2)
assert_equal "5DB3", determine_passcode(instructions, keypad: DIAMOND_KEYPAD, starting_position: starting_position)
end
end