-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_yatzy.rb
99 lines (83 loc) · 2.56 KB
/
test_yatzy.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
87
88
89
90
91
92
93
94
95
96
97
98
require_relative 'yatzy'
require 'test/unit'
class YatzyTest < Test::Unit::TestCase
def test_chance_scores_sum_of_all_dice
expected = 15
actual = Yatzy.chance(2,3,4,5,1)
assert expected == actual
assert 16 == Yatzy.chance(3,3,4,5,1)
end
def test_yatzy_scores_50
expected = 50
actual = Yatzy.yatzy([4,4,4,4,4])
assert expected == actual
assert 50 == Yatzy.yatzy([6,6,6,6,6])
assert 0 == Yatzy.yatzy([6,6,6,6,3])
end
def test_1s
assert Yatzy.ones(1,2,3,4,5) == 1
assert 2 == Yatzy.ones(1,2,1,4,5)
assert 0 == Yatzy.ones(6,2,2,4,5)
assert 4 == Yatzy.ones(1,2,1,1,1)
end
def test_2s
assert Yatzy.twos(1,2,3,2,6) == 4
assert Yatzy.twos(2,2,2,2,2) == 10
end
def test_threes
assert 6 == Yatzy.threes(1,2,3,2,3)
assert 12 == Yatzy.threes(2,3,3,3,3)
end
def test_fours_test
assert 12 == Yatzy.new(4,4,4,5,5).fours
assert 8 == Yatzy.new(4,4,5,5,5).fours
assert 4 == Yatzy.new(4,5,5,5,5).fours
end
def test_fives()
assert 10 == Yatzy.new(4,4,4,5,5).fives()
assert 15 == Yatzy.new(4,4,5,5,5).fives()
assert 20 == Yatzy.new(4,5,5,5,5).fives()
end
def test_sixes_test
assert 0 == Yatzy.new(4,4,4,5,5).sixes()
assert 6 == Yatzy.new(4,4,6,5,5).sixes()
assert 18 == Yatzy.new(6,5,6,6,5).sixes()
end
def test_one_pair
assert 6 == Yatzy.score_pair(3,4,3,5,6)
assert 10 == Yatzy.score_pair(5,3,3,3,5)
assert 10 == Yatzy.score_pair(5,5,3,3,5)
assert 12 == Yatzy.score_pair(5,3,6,6,5)
end
def test_two_Pair
assert_equal 16, Yatzy.two_pair(3,3,5,4,5)
assert_equal 16, Yatzy.two_pair(3,3,5,5,5)
end
def test_three_of_a_kind()
assert 9 == Yatzy.three_of_a_kind(3,3,3,4,5)
assert 15 == Yatzy.three_of_a_kind(5,3,5,4,5)
assert 9 == Yatzy.three_of_a_kind(3,3,3,3,5)
end
def test_four_of_a_knd
assert 12 == Yatzy.four_of_a_kind(3,3,3,3,5)
assert 20 == Yatzy.four_of_a_kind(5,5,5,4,5)
assert 9 == Yatzy.three_of_a_kind(3,3,3,3,3)
assert 12 == Yatzy.four_of_a_kind(3,3,3,3,3)
end
def test_smallStraight()
assert 15 == Yatzy.smallStraight(1,2,3,4,5)
assert 15 == Yatzy.smallStraight(2,3,4,5,1)
assert 0 == Yatzy.smallStraight(1,2,2,4,5)
end
def test_largeStraight
assert 20 == Yatzy.largeStraight(6,2,3,4,5)
assert 20 == Yatzy.largeStraight(2,3,4,5,6)
assert 0 == Yatzy.largeStraight(1,2,2,4,5)
end
def test_fullHouse()
assert 18 == Yatzy.fullHouse(6,2,2,2,6)
assert 0 == Yatzy.fullHouse(2,3,4,5,6)
assert 0 == Yatzy.fullHouse(3,3,3,1,5)
assert 0 == Yatzy.fullHouse(4,4,4,4,4)
end
end