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