|
|
@@ -1,14 +1,16 @@
|
|
1
|
1
|
import static org.junit.Assert.assertEquals;
|
|
|
2
|
+
|
|
2
|
3
|
import java.util.Arrays;
|
|
3
|
|
-import org.junit.Ignore;
|
|
|
4
|
+
|
|
4
|
5
|
import org.junit.Test;
|
|
5
|
6
|
|
|
6
|
|
-public class PokerTest
|
|
7
|
|
-{
|
|
|
7
|
+import jdk.nashorn.internal.ir.annotations.Ignore;
|
|
|
8
|
+
|
|
|
9
|
+public class PokerTest {
|
|
8
|
10
|
@Test
|
|
9
|
11
|
public void oneHand() {
|
|
10
|
12
|
final String hand = "4S 5S 7H 8D JC";
|
|
11
|
|
- assertEquals(Arrays.asList(hand),Poker.bestHands(Arrays.asList(hand)));
|
|
|
13
|
+ assertEquals(Arrays.asList(hand),new Poker(Arrays.asList(hand)).getBestHands());
|
|
12
|
14
|
}
|
|
13
|
15
|
|
|
14
|
16
|
@Test
|
|
|
@@ -16,7 +18,7 @@ public class PokerTest
|
|
16
|
18
|
public void nothingVsOnePair() {
|
|
17
|
19
|
final String nothing = "4S 5H 6S 8D JH";
|
|
18
|
20
|
final String pairOf4 = "2S 4H 6S 4D JH";
|
|
19
|
|
- assertEquals(Arrays.asList(pairOf4), Poker.bestHands(Arrays.asList(nothing, pairOf4)));
|
|
|
21
|
+ assertEquals(Arrays.asList(pairOf4),new Poker(Arrays.asList(nothing, pairOf4)).getBestHands());
|
|
20
|
22
|
}
|
|
21
|
23
|
|
|
22
|
24
|
@Test
|
|
|
@@ -24,7 +26,7 @@ public class PokerTest
|
|
24
|
26
|
public void twoPairs() {
|
|
25
|
27
|
final String pairOf2 = "4S 2H 6S 2D JH";
|
|
26
|
28
|
final String pairOf4 = "2S 4H 6S 4D JH";
|
|
27
|
|
- assertEquals(Arrays.asList(pairOf4), Poker.bestHands(Arrays.asList(pairOf2,pairOf4)));
|
|
|
29
|
+ assertEquals(Arrays.asList(pairOf4), new Poker(Arrays.asList(pairOf2,pairOf4)).getBestHands());
|
|
28
|
30
|
}
|
|
29
|
31
|
|
|
30
|
32
|
@Test
|
|
|
@@ -32,7 +34,7 @@ public class PokerTest
|
|
32
|
34
|
public void onePairVsDoublePair() {
|
|
33
|
35
|
final String pairOf8 = "2S 8H 6S 8D JH";
|
|
34
|
36
|
final String doublePair = "4S 5H 4S 8D 5H";
|
|
35
|
|
- assertEquals(Arrays.asList(doublePair), Poker.bestHands(Arrays.asList(pairOf8, doublePair)));
|
|
|
37
|
+ assertEquals(Arrays.asList(doublePair), new Poker(Arrays.asList(pairOf8, doublePair)).getBestHands());
|
|
36
|
38
|
}
|
|
37
|
39
|
|
|
38
|
40
|
@Test
|
|
|
@@ -40,7 +42,7 @@ public class PokerTest
|
|
40
|
42
|
public void twoDoublePairs() {
|
|
41
|
43
|
final String doublePair2And8 = "2S 8H 2S 8D JH";
|
|
42
|
44
|
final String doublePair4And5 = "4S 5H 4S 8D 5H";
|
|
43
|
|
- assertEquals(Arrays.asList(doublePair2And8), Poker.bestHands(Arrays.asList(doublePair2And8, doublePair4And5)));
|
|
|
45
|
+ assertEquals(Arrays.asList(doublePair2And8), new Poker(Arrays.asList(doublePair2And8, doublePair4And5)).getBestHands());
|
|
44
|
46
|
}
|
|
45
|
47
|
|
|
46
|
48
|
@Test
|
|
|
@@ -48,7 +50,7 @@ public class PokerTest
|
|
48
|
50
|
public void doublePairVsThree() {
|
|
49
|
51
|
final String doublePair2And8 = "2S 8H 2S 8D JH";
|
|
50
|
52
|
final String threeOf4 = "4S 5H 4S 8D 4H";
|
|
51
|
|
- assertEquals(Arrays.asList(threeOf4 ), Poker.bestHands(Arrays.asList(doublePair2And8, threeOf4 )));
|
|
|
53
|
+ assertEquals(Arrays.asList(threeOf4 ), new Poker(Arrays.asList(doublePair2And8, threeOf4)).getBestHands());
|
|
52
|
54
|
}
|
|
53
|
55
|
|
|
54
|
56
|
@Test
|
|
|
@@ -56,7 +58,7 @@ public class PokerTest
|
|
56
|
58
|
public void twoThrees() {
|
|
57
|
59
|
final String threeOf2 = "2S 2H 2S 8D JH";
|
|
58
|
60
|
final String threeOf1 = "4S AH AS 8D AH";
|
|
59
|
|
- assertEquals(Arrays.asList(threeOf1), Poker.bestHands(Arrays.asList(threeOf2, threeOf1)));
|
|
|
61
|
+ assertEquals(Arrays.asList(threeOf1), new Poker(Arrays.asList(threeOf2, threeOf1)).getBestHands());
|
|
60
|
62
|
}
|
|
61
|
63
|
|
|
62
|
64
|
@Test
|
|
|
@@ -64,7 +66,7 @@ public class PokerTest
|
|
64
|
66
|
public void threeVsStraight() {
|
|
65
|
67
|
final String threeOf4 = "4S 5H 4S 8D 4H";
|
|
66
|
68
|
final String straight = "3S 4H 2S 6D 5H";
|
|
67
|
|
- assertEquals(Arrays.asList(straight), Poker.bestHands(Arrays.asList(threeOf4, straight )));
|
|
|
69
|
+ assertEquals(Arrays.asList(straight), new Poker(Arrays.asList(threeOf4, straight)).getBestHands());
|
|
68
|
70
|
}
|
|
69
|
71
|
|
|
70
|
72
|
@Test
|
|
|
@@ -72,11 +74,11 @@ public class PokerTest
|
|
72
|
74
|
public void twoStraights() {
|
|
73
|
75
|
final String straightTo8 = "4S 6H 7S 8D 5H";
|
|
74
|
76
|
final String straightTo9 = "5S 7H 8S 9D 6H";
|
|
75
|
|
- assertEquals(Arrays.asList(straightTo9 ), Poker.bestHands(Arrays.asList(straightTo8, straightTo9 )));
|
|
|
77
|
+ assertEquals(Arrays.asList(straightTo9 ), new Poker(Arrays.asList(straightTo8, straightTo9)).getBestHands());
|
|
76
|
78
|
|
|
77
|
79
|
final String straightTo1 = "AS QH KS TD JH";
|
|
78
|
80
|
final String straightTo5 = "4S AH 3S 2D 5H";
|
|
79
|
|
- assertEquals(Arrays.asList(straightTo1), Poker.bestHands(Arrays.asList(straightTo1, straightTo5)));
|
|
|
81
|
+ assertEquals(Arrays.asList(straightTo1), new Poker(Arrays.asList(straightTo1, straightTo5)).getBestHands());
|
|
80
|
82
|
}
|
|
81
|
83
|
|
|
82
|
84
|
@Test
|
|
|
@@ -84,7 +86,7 @@ public class PokerTest
|
|
84
|
86
|
public void straightVsFlush() {
|
|
85
|
87
|
final String straightTo8 = "4S 6H 7S 8D 5H";
|
|
86
|
88
|
final String flushTo7 = "2S 4S 5S 6S 7S";
|
|
87
|
|
- assertEquals(Arrays.asList(flushTo7 ), Poker.bestHands(Arrays.asList(straightTo8, flushTo7 )));
|
|
|
89
|
+ assertEquals(Arrays.asList(flushTo7 ), new Poker(Arrays.asList(straightTo8, flushTo7)).getBestHands());
|
|
88
|
90
|
}
|
|
89
|
91
|
|
|
90
|
92
|
@Test
|
|
|
@@ -92,7 +94,7 @@ public class PokerTest
|
|
92
|
94
|
public void twoFlushes() {
|
|
93
|
95
|
final String flushTo8 = "3H 6H 7H 8H 5H";
|
|
94
|
96
|
final String flushTo7 = "2S 4S 5S 6S 7S";
|
|
95
|
|
- assertEquals(Arrays.asList(flushTo8), Poker.bestHands(Arrays.asList(flushTo8, flushTo7)));
|
|
|
97
|
+ assertEquals(Arrays.asList(flushTo8), new Poker(Arrays.asList(flushTo8, flushTo7)).getBestHands());
|
|
96
|
98
|
}
|
|
97
|
99
|
|
|
98
|
100
|
@Test
|
|
|
@@ -100,7 +102,7 @@ public class PokerTest
|
|
100
|
102
|
public void flushVsFull() {
|
|
101
|
103
|
final String flushTo8 = "3H 6H 7H 8H 5H";
|
|
102
|
104
|
final String full = "4S 5H 4S 5D 4H";
|
|
103
|
|
- assertEquals(Arrays.asList(full ), Poker.bestHands(Arrays.asList(full, flushTo8)));
|
|
|
105
|
+ assertEquals(Arrays.asList(full ), new Poker(Arrays.asList(full, flushTo8)).getBestHands());
|
|
104
|
106
|
}
|
|
105
|
107
|
|
|
106
|
108
|
@Test
|
|
|
@@ -108,7 +110,7 @@ public class PokerTest
|
|
108
|
110
|
public void twoFulls() {
|
|
109
|
111
|
final String fullOf4By9 = "4H 4S 4D 9S 9D";
|
|
110
|
112
|
final String fullOf5By8 = "5H 5S 5D 8S 8D";
|
|
111
|
|
- assertEquals(Arrays.asList(fullOf5By8 ), Poker.bestHands(Arrays.asList(fullOf4By9, fullOf5By8)));
|
|
|
113
|
+ assertEquals(Arrays.asList(fullOf5By8 ), new Poker(Arrays.asList(fullOf4By9, fullOf5By8)).getBestHands());
|
|
112
|
114
|
}
|
|
113
|
115
|
|
|
114
|
116
|
@Test
|
|
|
@@ -116,7 +118,7 @@ public class PokerTest
|
|
116
|
118
|
public void fullVsSquare() {
|
|
117
|
119
|
final String full = "4S 5H 4S 5D 4H";
|
|
118
|
120
|
final String squareOf3 = "3S 3H 2S 3D 3H";
|
|
119
|
|
- assertEquals(Arrays.asList(squareOf3 ), Poker.bestHands(Arrays.asList(full, squareOf3 )));
|
|
|
121
|
+ assertEquals(Arrays.asList(squareOf3 ), new Poker(Arrays.asList(full, squareOf3)).getBestHands());
|
|
120
|
122
|
}
|
|
121
|
123
|
|
|
122
|
124
|
@Test
|
|
|
@@ -124,7 +126,7 @@ public class PokerTest
|
|
124
|
126
|
public void twoSquares() {
|
|
125
|
127
|
final String squareOf2 = "2S 2H 2S 8D 2H";
|
|
126
|
128
|
final String squareOf5 = "4S 5H 5S 5D 5H";
|
|
127
|
|
- assertEquals(Arrays.asList(squareOf5), Poker.bestHands(Arrays.asList(squareOf2, squareOf5)));
|
|
|
129
|
+ assertEquals(Arrays.asList(squareOf5), new Poker(Arrays.asList(squareOf2, squareOf5)).getBestHands());
|
|
128
|
130
|
}
|
|
129
|
131
|
|
|
130
|
132
|
@Test
|
|
|
@@ -132,7 +134,7 @@ public class PokerTest
|
|
132
|
134
|
public void squareVsStraightFlush() {
|
|
133
|
135
|
final String squareOf5 = "4S 5H 5S 5D 5H";
|
|
134
|
136
|
final String straightFlushTo9 = "5S 7S 8S 9S 6S";
|
|
135
|
|
- assertEquals(Arrays.asList(straightFlushTo9 ), Poker.bestHands(Arrays.asList(squareOf5, straightFlushTo9 )));
|
|
|
137
|
+ assertEquals(Arrays.asList(straightFlushTo9 ), new Poker(Arrays.asList(squareOf5, straightFlushTo9)).getBestHands());
|
|
136
|
138
|
}
|
|
137
|
139
|
|
|
138
|
140
|
@Test
|
|
|
@@ -140,7 +142,7 @@ public class PokerTest
|
|
140
|
142
|
public void twoStraightFlushes() {
|
|
141
|
143
|
final String straightFlushTo8 = "4H 6H 7H 8H 5H";
|
|
142
|
144
|
final String straightFlushTo9 = "5S 7S 8S 9S 6S";
|
|
143
|
|
- assertEquals(Arrays.asList(straightFlushTo9 ), Poker.bestHands(Arrays.asList(straightFlushTo8, straightFlushTo9)));
|
|
|
145
|
+ assertEquals(Arrays.asList(straightFlushTo9 ), new Poker(Arrays.asList(straightFlushTo8, straightFlushTo9)).getBestHands());
|
|
144
|
146
|
}
|
|
145
|
147
|
|
|
146
|
148
|
@Test
|
|
|
@@ -149,7 +151,7 @@ public class PokerTest
|
|
149
|
151
|
final String spadeStraightTo9 = "9S 8S 7S 6S 5S";
|
|
150
|
152
|
final String diamondStraightTo9 = "9D 8D 7D 6D 5D";
|
|
151
|
153
|
final String threeOf4 = "4D 4S 4H QS KS";
|
|
152
|
|
- assertEquals(Arrays.asList(spadeStraightTo9, diamondStraightTo9), Poker.bestHands(Arrays.asList(spadeStraightTo9, diamondStraightTo9, threeOf4)));
|
|
|
154
|
+ assertEquals(Arrays.asList(spadeStraightTo9, diamondStraightTo9), new Poker(Arrays.asList(spadeStraightTo9, diamondStraightTo9, threeOf4)).getBestHands());
|
|
153
|
155
|
}
|
|
154
|
156
|
|
|
155
|
157
|
@Test
|
|
|
@@ -157,6 +159,6 @@ public class PokerTest
|
|
157
|
159
|
public void straightTo5AgainstAPairOfJacks() {
|
|
158
|
160
|
final String straightTo5 = "2S 4D 5C 3S AS";
|
|
159
|
161
|
final String twoJacks = "JD 8D 7D JC 5D";
|
|
160
|
|
- assertEquals(Arrays.asList(straightTo5), Poker.bestHands(Arrays.asList(straightTo5, twoJacks)));
|
|
|
162
|
+ assertEquals(Arrays.asList(straightTo5), new Poker(Arrays.asList(straightTo5, twoJacks)).getBestHands());
|
|
161
|
163
|
}
|
|
162
|
164
|
}
|