From f22ff5f0f1d8f9838c30943bde658ca3f282bbc8 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Tue, 31 May 2011 00:58:46 +0200 Subject: =?UTF-8?q?Tests=20f=C3=BCr=20Sets=20mit=20mehr=20Farben,=20mehr?= =?UTF-8?q?=20Values,=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@332 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/RoundControlTest.java | 109 +++++++------- test/jrummikub/control/turn/TurnControlTest.java | 6 +- test/jrummikub/model/StoneHeapTest.java | 27 ++-- test/jrummikub/model/StoneSetTest.java | 182 ++++++++++++++++------- test/jrummikub/model/TableTest.java | 2 +- 5 files changed, 205 insertions(+), 121 deletions(-) (limited to 'test') diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index fd2d3fb..f5afeea 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -70,8 +70,10 @@ public class RoundControlTest { gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED)); gameSettings.getPlayerList().add( new PlayerSettings("Matthias", Color.YELLOW)); - gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN)); - gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK)); + gameSettings.getPlayerList().add( + new PlayerSettings("Jannis", Color.GREEN)); + gameSettings.getPlayerList().add( + new PlayerSettings("Bennet", Color.BLACK)); roundState = new RoundState(gameSettings); roundControl = new RoundControl(roundState, view); } @@ -81,7 +83,8 @@ public class RoundControlTest { - testRoundState.table.getSize(), testRoundState.getGameHeap() .getSize()); for (int i = 0; i < testRoundState.getPlayerCount(); i++) { - assertEquals(14, testRoundState.getNthNextPlayer(i).getHand().getSize()); + assertEquals(14, testRoundState.getNthNextPlayer(i).getHand() + .getSize()); } } @@ -142,8 +145,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 6, hand.getSize()); } @@ -163,8 +166,8 @@ public class RoundControlTest { assertFalse(roundState.getActivePlayer().getLaidOut()); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 1, hand.getSize()); } @@ -211,8 +214,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 9, hand.getSize()); } @@ -282,8 +285,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 6, hand.getSize()); } @@ -356,8 +359,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 7, hand.getSize()); } @@ -420,8 +423,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) - .getLaidOut()); + assertFalse(roundState + .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 3, hand.getSize()); } @@ -679,12 +682,15 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); Stone blueFour = new Stone(4, BLUE); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne)); + StoneSet oldSet1 = new StoneSet( + Arrays.asList(blueOne, redOne, blackOne)); StoneSet oldSet2 = new StoneSet(blueTwo); oldTable.drop(oldSet1, new Position(0, 0)); oldTable.drop(oldSet2, new Position(0, 0)); - StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour)); - StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree)); + StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, + blueFour)); + StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, + blueThree)); newTable.drop(newSet1, new Position(0, 0)); newTable.drop(newSet2, new Position(0, 0)); @@ -701,7 +707,7 @@ public class RoundControlTest { /** */ @Test public void testTableSetDifference() { - ITable oldTable = new Table(); + ITable oldTable = new Table(gameSettings); Stone blueOne = new Stone(1, BLUE); Stone redOne = new Stone(1, RED); Stone blackOne = new Stone(1, BLACK); @@ -709,14 +715,15 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); Stone blueFour = new Stone(4, BLUE); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, - orangeOne)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, + blackOne, orangeOne)); + StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, + blueFour)); oldTable.drop(oldSet1, new Position(0, 0)); oldTable.drop(oldSet2, new Position(0, 0)); ITable newTable = (Table) oldTable.clone(); - List newSets = RoundControl - .tableSetDifference(oldTable, newTable); + List newSets = RoundControl.tableSetDifference(oldTable, + newTable); List vanishedSets = RoundControl.tableSetDifference(newTable, oldTable); @@ -724,8 +731,8 @@ public class RoundControlTest { assertTrue(vanishedSets.isEmpty()); newTable.pickUp(oldSet2); - newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position( - 0, 0)); + newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), + new Position(0, 0)); newSets = RoundControl.tableSetDifference(oldTable, newTable); vanishedSets = RoundControl.tableSetDifference(newTable, oldTable); @@ -737,7 +744,8 @@ public class RoundControlTest { Stone redTwo = new Stone(2, RED); Stone redThree = new Stone(3, RED); Stone redFour = new Stone(4, RED); - StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour)); + StoneSet oldSet3 = new StoneSet( + Arrays.asList(redTwo, redThree, redFour)); ITable newTable2 = (Table) oldTable.clone(); newTable2.drop(oldSet3, new Position(0, 0)); newSets = RoundControl.tableSetDifference(oldTable, newTable2); @@ -799,19 +807,20 @@ public class RoundControlTest { } testRoundState.players.get(0).laidOut = true; - testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0, - 0)); - testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0, - 0)); + testRoundState.players.get(0).hand.drop(new Stone(1, RED), + new Position(0, 0)); + testRoundState.players.get(0).hand.drop(new Stone(2, RED), + new Position(0, 0)); testRoundState.players.get(1).laidOut = true; - testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0)); - testRoundState.players.get(2).laidOut = false; - testRoundState.players.get(2).hand.drop(new Stone(9, RED), new Position(0, - 0)); - testRoundState.players.get(2).hand.drop(new Stone(10, RED), new Position(0, - 0)); - testRoundState.players.get(2).hand.drop(new Stone(11, RED), new Position(0, + testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0)); + testRoundState.players.get(2).laidOut = false; + testRoundState.players.get(2).hand.drop(new Stone(9, RED), + new Position(0, 0)); + testRoundState.players.get(2).hand.drop(new Stone(10, RED), + new Position(0, 0)); + testRoundState.players.get(2).hand.drop(new Stone(11, RED), + new Position(0, 0)); testRoundState.players.get(3).laidOut = true; testRound.endOfRound(); @@ -845,19 +854,19 @@ public class RoundControlTest { } testRoundState.players.get(0).laidOut = true; - testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0, - 0)); - testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0, - 0)); + testRoundState.players.get(0).hand.drop(new Stone(1, RED), + new Position(0, 0)); + testRoundState.players.get(0).hand.drop(new Stone(2, RED), + new Position(0, 0)); testRoundState.players.get(1).laidOut = true; - testRoundState.players.get(1).hand.drop(new Stone(3, RED), new Position(0, - 0)); + testRoundState.players.get(1).hand.drop(new Stone(3, RED), + new Position(0, 0)); testRoundState.players.get(2).laidOut = true; - testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), new Position(0, - 0)); + testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), + new Position(0, 0)); testRoundState.players.get(3).laidOut = false; - testRoundState.players.get(3).hand.drop(new Stone(13, RED), new Position(0, - 0)); + testRoundState.players.get(3).hand.drop(new Stone(13, RED), + new Position(0, 0)); testRound.endOfRound(); assertTrue(roundEnded); @@ -905,7 +914,7 @@ public class RoundControlTest { view.playerPanel.redealEvent.emit(); assertTrue(roundRestarted); } - + /** */ @Test public void testRedealDisallowed() { @@ -924,7 +933,7 @@ public class RoundControlTest { } assertFalse(view.playerPanel.inspectOnly); } - + /** */ @Test public void testRedealAllowed() { diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java index 11c4c2b..db382ca 100644 --- a/test/jrummikub/control/turn/TurnControlTest.java +++ b/test/jrummikub/control/turn/TurnControlTest.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Set; import jrummikub.control.ITurnTimer; -import jrummikub.control.turn.HumanTurnControl; +import jrummikub.model.GameSettings; import jrummikub.model.IHand; import jrummikub.model.ITable; import jrummikub.model.MockHand; @@ -45,6 +45,10 @@ public class TurnControlTest { StoneSet[] getSetArray() { return objects.keySet().toArray(new StoneSet[0]); } + + AccessibleTable (){ + super (new GameSettings()); + } } class MockTimer implements ITurnTimer { diff --git a/test/jrummikub/model/StoneHeapTest.java b/test/jrummikub/model/StoneHeapTest.java index 811a2d1..f0b88d3 100644 --- a/test/jrummikub/model/StoneHeapTest.java +++ b/test/jrummikub/model/StoneHeapTest.java @@ -1,8 +1,8 @@ package jrummikub.model; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,8 +20,10 @@ import org.junit.runner.RunWith; @RunWith(Theories.class) public class StoneHeapTest { - private static Pair createHeap(GameSettings settings) { - return new Pair(settings, new StoneHeap(settings)); + private static Pair createHeap( + GameSettings settings) { + return new Pair(settings, new StoneHeap( + settings)); } /** @@ -54,7 +56,8 @@ public class StoneHeapTest { private int calculateTotalNumberOfStones(GameSettings testSettings) { int totalStones = testSettings.getHighestCard() * testSettings.getStoneSetNumber() - * testSettings.getStoneColors().size() + testSettings.getJokerNumber(); + * testSettings.getStoneColors().size() + + testSettings.getJokerNumber(); return totalStones; } @@ -62,7 +65,7 @@ public class StoneHeapTest { * Is the right number of Stones in heap? * * @param data - * data + * data */ @Theory public void fullStoneHeap(Pair data) { @@ -74,14 +77,14 @@ public class StoneHeapTest { * Enough stones of each color in heap? * * @param data - * data + * data */ @Theory public void fullColor(Pair data) { int stonesOfAColor = data.getFirst().getHighestCard() * data.getFirst().getStoneSetNumber(); Map counters = new HashMap(); - for (StoneColor c : EnumSet.allOf(StoneColor.class)) { + for (StoneColor c : data.getFirst().getStoneColors()) { counters.put(c, 0); } for (Stone i : data.getSecond().heap) { @@ -90,7 +93,7 @@ public class StoneHeapTest { int count = counters.get(i.getColor()); counters.put(i.getColor(), count + 1); } - for (StoneColor c : EnumSet.allOf(StoneColor.class)) { + for (StoneColor c : data.getFirst().getStoneColors()) { assertEquals(stonesOfAColor, (long) counters.get(c)); } } @@ -99,7 +102,7 @@ public class StoneHeapTest { * Enough Jokers? * * @param data - * data + * data */ @Theory public void fullJoker(Pair data) { @@ -113,7 +116,7 @@ public class StoneHeapTest { /** * @param data - * data + * data */ @Theory public void drawStoneTest(Pair data) { @@ -124,7 +127,7 @@ public class StoneHeapTest { /** * @param data - * data + * data */ @Theory public void drawStonesTest(Pair data) { diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java index f53163e..a5c44f0 100644 --- a/test/jrummikub/model/StoneSetTest.java +++ b/test/jrummikub/model/StoneSetTest.java @@ -1,91 +1,136 @@ package jrummikub.model; +import static jrummikub.model.StoneColor.*; +import static jrummikub.model.StoneSet.Type.*; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumSet; +import java.util.HashSet; import java.util.List; import jrummikub.util.Pair; -import static jrummikub.model.StoneColor.*; -import static jrummikub.model.StoneSet.Type.*; -import org.junit.*; -import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; /** * Tests for {@link StoneSet} */ public class StoneSetTest { + private GameSettings defaultSettings = new GameSettings(); + private GameSettings moreColorSettings = new GameSettings(); + private GameSettings lessColorSettings = new GameSettings(); + private GameSettings higherValueSettings = new GameSettings(); + private GameSettings lowerValueSettings = new GameSettings(); + + /** */ + @Before + public void setUpSettings() { + moreColorSettings.setStoneColors(EnumSet.allOf(StoneColor.class)); + lessColorSettings.setStoneColors(new HashSet(Arrays.asList( + StoneColor.BLUE, StoneColor.RED, StoneColor.BLACK))); + higherValueSettings.setHighestCard(17); + lowerValueSettings.setHighestCard(10); + } private void assertSet(StoneSet.Type expectedType, Integer expectedValue, - List stones) { + List stones, GameSettings settings) { StoneSet set = new StoneSet(stones); - assertSame(expectedType, set.classify().getFirst()); - assertEquals(expectedValue, set.classify().getSecond()); + assertSame(expectedType, set.classify(settings).getFirst()); + assertEquals(expectedValue, set.classify(settings).getSecond()); } // valid+point count /** */ @Test - public void doubleJoker() { + public void doubleJokerValid() { // 3 Stones // JJZ assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(1, BLACK))); + new Stone(1, BLACK)), defaultSettings); // JZJ assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, BLACK), - new Stone(BLACK))); + new Stone(BLACK)), defaultSettings); // ZJJ assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), - new Stone(BLACK))); + new Stone(BLACK)), defaultSettings); + assertSet(RUN, 33, Arrays.asList(new Stone(10, RED), new Stone(RED), + new Stone(BLACK)), defaultSettings); + assertSet(GROUP, 30, Arrays.asList(new Stone(10, RED), new Stone(RED), + new Stone(BLACK)), lowerValueSettings); + assertSet(GROUP, 39, Arrays.asList(new Stone(13, RED), new Stone(RED), + new Stone(BLACK)), defaultSettings); + assertSet(RUN, 42, Arrays.asList(new Stone(13, RED), new Stone(RED), + new Stone(BLACK)), higherValueSettings); // 4 Stones // JJZZ assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(1, BLACK), new Stone(1, RED))); + new Stone(1, BLACK), new Stone(1, RED)), defaultSettings); assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(3, RED), new Stone(4, RED))); + new Stone(3, RED), new Stone(4, RED)), defaultSettings); // ZZJJ assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(2, RED), - new Stone(BLACK), new Stone(RED))); + new Stone(BLACK), new Stone(RED)), defaultSettings); assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), - new Stone(1, BLACK), new Stone(BLACK), new Stone(RED))); + new Stone(1, BLACK), new Stone(BLACK), new Stone(RED)), + defaultSettings); // ZJZJ assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), new Stone(BLACK), - new Stone(1, BLACK), new Stone(RED))); + new Stone(1, BLACK), new Stone(RED)), defaultSettings); assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(RED), - new Stone(3, RED), new Stone(BLACK))); + new Stone(3, RED), new Stone(BLACK)), defaultSettings); // JZJZ assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(1, BLACK), - new Stone(BLACK), new Stone(1, RED))); + new Stone(BLACK), new Stone(1, RED)), defaultSettings); assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(2, RED), - new Stone(BLACK), new Stone(4, RED))); + new Stone(BLACK), new Stone(4, RED)), defaultSettings); // JZZJ assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(1, BLACK), - new Stone(1, RED), new Stone(BLACK))); + new Stone(1, RED), new Stone(BLACK)), defaultSettings); assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(2, RED), - new Stone(3, RED), new Stone(BLACK))); + new Stone(3, RED), new Stone(BLACK)), defaultSettings); // ZJJZ assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), new Stone(BLACK), - new Stone(RED), new Stone(1, BLACK))); + new Stone(RED), new Stone(1, BLACK)), defaultSettings); assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(RED), - new Stone(BLACK), new Stone(4, RED))); + new Stone(BLACK), new Stone(4, RED)), defaultSettings); + // More than 4 stones + assertSet(GROUP, 6, Arrays.asList(new Stone(1, RED), + new Stone(1, BLUE), new Stone(1, GREEN), new Stone(1, BLACK), + new Stone(BLACK), new Stone(RED)), moreColorSettings); } /** */ @Test public void groups() { assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), - new Stone(1, BLACK), new Stone(1, BLUE))); + new Stone(1, BLACK), new Stone(1, BLUE)), defaultSettings); + assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), + new Stone(1, BLACK), new Stone(1, BLUE)), lessColorSettings); assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), - new Stone(1, BLACK), new Stone(1, BLUE), new Stone(1, ORANGE))); + new Stone(1, BLACK), new Stone(1, BLUE), new Stone(1, ORANGE)), + defaultSettings); + assertSet(GROUP, 6, Arrays.asList(new Stone(1, RED), + new Stone(1, GREEN), new Stone(1, WHITE), new Stone(1, BLACK), + new Stone(1, BLUE), new Stone(1, ORANGE)), moreColorSettings); } /** */ @Test public void runs() { assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), - new Stone(3, RED))); + new Stone(3, RED)), defaultSettings); + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), + new Stone(3, RED)), lowerValueSettings); + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), + new Stone(3, RED)), higherValueSettings); assertSet(RUN, 22, Arrays.asList(new Stone(4, BLUE), - new Stone(5, BLUE), new Stone(6, BLUE), new Stone(7, BLUE))); + new Stone(5, BLUE), new Stone(6, BLUE), new Stone(7, BLUE)), + defaultSettings); + assertSet(RUN, 42, Arrays.asList(new Stone(13, RED), + new Stone(14, RED), new Stone(15, RED)), higherValueSettings); } /** */ @@ -93,84 +138,107 @@ public class StoneSetTest { public void singleJoker() { // ZJZ assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), new Stone(BLACK), - new Stone(1, BLACK))); + new Stone(1, BLACK)), defaultSettings); assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), - new Stone(3, RED))); + new Stone(3, RED)), defaultSettings); // JZZ assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, RED), - new Stone(1, BLACK))); + new Stone(1, BLACK)), defaultSettings); assertSet(RUN, 6, Arrays.asList(new Stone(RED), new Stone(2, RED), - new Stone(3, RED))); + new Stone(3, RED)), defaultSettings); // ZZJ assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), - new Stone(1, BLACK), new Stone(BLACK))); + new Stone(1, BLACK), new Stone(BLACK)), defaultSettings); assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), - new Stone(RED))); + new Stone(RED)), defaultSettings); + assertSet(RUN, 39, Arrays.asList(new Stone(12, RED), + new Stone(13, RED), new Stone(RED)), higherValueSettings); } // invalid + /** */ + @Test + public void doubleJokerInvalid() { + assertSet(INVALID, 0, Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(1, BLACK), new Stone(1, RED)), lessColorSettings); + // More than 4 stones + assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), new Stone(1, + BLUE), new Stone(1, GREEN), new Stone(1, BLACK), new Stone(1, + VIOLET), new Stone(1, ORANGE), new Stone(1, BROWN), new Stone( + BLACK), new Stone(RED)), moreColorSettings); + } + /** */ @Test public void outOfBounds() { assertSet(INVALID, 0, Arrays.asList(new Stone(RED), new Stone(1, RED), - new Stone(2, RED))); + new Stone(2, RED)), defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(12, RED), new Stone(13, - RED), new Stone(RED))); + RED), new Stone(RED)), defaultSettings); + assertSet(INVALID, 0, Arrays.asList(new Stone(9, RED), new Stone(10, + RED), new Stone(RED)), lowerValueSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(1, RED), new Stone(2, RED))); + new Stone(1, RED), new Stone(2, RED)), defaultSettings); } /** */ @Test public void sameColor() { assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), - new Stone(1, RED), new Stone(1, BLUE))); + new Stone(1, RED), new Stone(1, BLUE)), defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), new Stone(1, BLUE), new Stone(1, BLACK), new Stone(1, ORANGE), - new Stone(RED))); + new Stone(RED)), defaultSettings); + assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), new Stone(1, + BLUE), new Stone(1, GREEN), new Stone(1, BLACK), new Stone(1, + VIOLET), new Stone(1, WHITE), new Stone(1, ORANGE), new Stone( + 1, BROWN), new Stone(RED)), moreColorSettings); } /** */ @Test public void incorrectOrder() { assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), - new Stone(6, RED), new Stone(5, RED))); + new Stone(6, RED), new Stone(5, RED)), defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), - new Stone(6, RED), new Stone(RED))); + new Stone(6, RED), new Stone(RED)), defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), new Stone(RED), - new Stone(5, RED))); + new Stone(5, RED)), defaultSettings); } /** */ @Test public void otherInvalid() { - assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), - new Stone(5, RED), new Stone(7, RED))); + new Stone(5, RED), new Stone(7, RED)), defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), new Stone(5, - BLUE), new Stone(6, RED))); + BLUE), new Stone(6, RED)), defaultSettings); assertSet(INVALID, 0, - Arrays.asList(new Stone(4, RED), new Stone(5, RED))); + Arrays.asList(new Stone(4, RED), new Stone(5, RED)), + defaultSettings); assertSet(INVALID, 0, Arrays.asList(new Stone(4, BLUE), new Stone(5, - RED), new Stone(6, RED))); + RED), new Stone(6, RED)), defaultSettings); // Regression test: assertSet(INVALID, 0, Arrays.asList(new Stone(12, ORANGE), new Stone( - 12, BLACK), new Stone(7, BLUE))); + 12, BLACK), new Stone(7, BLUE)), defaultSettings); } /** */ @Test public void manyJokersValid() { - assertSet(GROUP, 3 * 13, Arrays.asList(new Stone(RED), - new Stone(RED), new Stone(RED))); - assertSet(GROUP, 4 * 13, Arrays.asList(new Stone(RED), - new Stone(RED), new Stone(RED), new Stone(RED))); - assertSet(RUN, 13 + 12 + 11 + 10 + 9, Arrays.asList(new Stone(RED), - new Stone(RED), new Stone(RED), new Stone(RED), new Stone(RED))); - assertSet(RUN, 5 * 10, Arrays.asList(new Stone(RED), - new Stone(RED), new Stone(RED), new Stone(RED), new Stone(12, RED))); + assertSet(GROUP, 3 * 13, + Arrays.asList(new Stone(RED), new Stone(RED), new Stone(RED)), + defaultSettings); + assertSet(GROUP, 4 * 13, Arrays.asList(new Stone(RED), new Stone(RED), + new Stone(RED), new Stone(RED)), defaultSettings); + assertSet(RUN, 13 + 12 + 11 + 10 + 9, + Arrays.asList(new Stone(RED), new Stone(RED), new Stone(RED), + new Stone(RED), new Stone(RED)), defaultSettings); + assertSet(RUN, 5 * 10, Arrays.asList(new Stone(RED), new Stone(RED), + new Stone(RED), new Stone(RED), new Stone(12, RED)), + defaultSettings); } - + /** */ @Test public void manyJokersInvalid() { @@ -178,7 +246,7 @@ public class StoneSetTest { for (int i = 0; i < 14; i++) { stones.add(new Stone(RED)); } - assertSet(INVALID, 0, stones); + assertSet(INVALID, 0, stones, defaultSettings); } // invalid Split diff --git a/test/jrummikub/model/TableTest.java b/test/jrummikub/model/TableTest.java index 0d53aed..d8e622f 100644 --- a/test/jrummikub/model/TableTest.java +++ b/test/jrummikub/model/TableTest.java @@ -21,7 +21,7 @@ public class TableTest { /** */ @Before public void setup() { - testTable = new Table(); + testTable = new Table(new GameSettings()); } /** */ -- cgit v1.2.3