-
Notifications
You must be signed in to change notification settings - Fork 2
/
leddisplay_tests.rb
86 lines (72 loc) · 1.83 KB
/
leddisplay_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require "test/unit"
require './leddisplay.rb'
class LedDisplayTest < Test::Unit::TestCase
# _ _
# | _| _|
# | |_ _|
def test_should_convert_zero
@d = LedDisplay.new
@result = @d.convert 0
assert_equal " _ \n| |\n|_|", @result
end
def test_should_convert_one
@d = LedDisplay.new
@result = @d.convert 1
assert_equal " \n |\n |", @result
end
def test_should_convert_two
@d = LedDisplay.new
@result = @d.convert 2
assert_equal " _ \n _|\n|_ ", @result
end
def test_should_convert_three
@d = LedDisplay.new
@result = @d.convert 3
assert_equal " _ \n _|\n _|", @result
end
def test_should_convert_four
@d = LedDisplay.new
@result = @d.convert 4
assert_equal " \n|_|\n |", @result
end
def test_should_convert_five
@d = LedDisplay.new
@result = @d.convert 5
assert_equal " _ \n|_ \n _|", @result
end
def test_should_convert_six
@d = LedDisplay.new
@result = @d.convert 6
assert_equal " _ \n|_ \n|_|", @result
end
def test_should_convert_seven
@d = LedDisplay.new
@result = @d.convert 7
assert_equal " _ \n |\n |", @result
end
def test_should_convert_eight
@d = LedDisplay.new
@result = @d.convert 8
assert_equal " _ \n|_|\n|_|", @result
end
def test_should_convert_nine
@d = LedDisplay.new
@result = @d.convert 9
assert_equal " _ \n|_|\n _|", @result
end
def test_should_convert_two_digit_number
@d = LedDisplay.new
@result = @d.convert 12
assert_equal " _ \n | _|\n | |_ ", @result
end
def test_should_convert_three_digit_number
@d = LedDisplay.new
@result = @d.convert 345
assert_equal " _ _ \n _| |_| |_ \n _| | _|", @result
end
def test_should_convert_five_digit_number
@d = LedDisplay.new
@result = @d.convert 67890
assert_equal " _ _ _ _ _ \n|_ | |_| |_| | |\n|_| | |_| _| |_|", @result
end
end