aoc2023/day_1/test.rb

42 lines
619 B
Ruby
Raw Permalink Normal View History

2023-12-01 10:00:04 +01:00
if ARGV[0] == "2"
require_relative "impl_2"
RESULT = 281
else
require_relative "impl"
RESULT = 142
end
INPUT = <<~IN
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
IN
INPUT_2 = <<~IN
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
IN
def test_example
input = ARGV[0] == "2" ? INPUT_2 : INPUT
parsed = parse(input)
result = calculate(parsed)
if result == RESULT
puts "Test successful. Now run with real input"
puts "ruby day_1/run.rb #{ARGV[0]}"
else
puts "Test failed"
puts "expected \"#{RESULT}\" got \"#{result}\""
end
end
test_example