diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-11 03:15:15 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-11 03:15:15 +0200 |
commit | acc1b64fe7824d1d1de62e0542129daa305a6ebe (patch) | |
tree | 4f22f04ab245c67c432f403645b896acc0aae37f /test/jrummikub | |
parent | f4972b339ba28ee83cee08aa090039edfff12e30 (diff) | |
download | JRummikub-acc1b64fe7824d1d1de62e0542129daa305a6ebe.tar JRummikub-acc1b64fe7824d1d1de62e0542129daa305a6ebe.zip |
Add test for no limits
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@411 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub')
-rw-r--r-- | test/jrummikub/model/StoneSetTest.java | 256 |
1 files changed, 163 insertions, 93 deletions
diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java index fda4c6c..b299d2c 100644 --- a/test/jrummikub/model/StoneSetTest.java +++ b/test/jrummikub/model/StoneSetTest.java @@ -24,6 +24,8 @@ public class StoneSetTest { private GameSettings lessColorSettings = new GameSettings(); private GameSettings higherValueSettings = new GameSettings(); private GameSettings lowerValueSettings = new GameSettings(); + private GameSettings noLimitsSettings = new GameSettings(); + private GameSettings noLimitsLowerValueSettings = new GameSettings(); /** */ @Before @@ -33,6 +35,9 @@ public class StoneSetTest { StoneColor.BLUE, StoneColor.RED, StoneColor.BLACK))); higherValueSettings.setHighestValue(17); lowerValueSettings.setHighestValue(10); + noLimitsSettings.setNoLimits(true); + noLimitsLowerValueSettings.setHighestValue(10); + noLimitsLowerValueSettings.setNoLimits(true); } private void assertSet(StoneSet.Type expectedType, Integer expectedValue, @@ -48,22 +53,29 @@ public class StoneSetTest { public void doubleJokerValid() { // 3 Stones // JJZ - assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(1, BLACK)), defaultSettings); + assertSet(GROUP, 3, + Arrays.asList(new Stone(RED), new Stone(BLACK), new Stone(1, BLACK)), + defaultSettings); // JZJ - assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, BLACK), - new Stone(BLACK)), defaultSettings); + assertSet(GROUP, 3, + Arrays.asList(new Stone(RED), new Stone(1, BLACK), new Stone(BLACK)), + defaultSettings); // ZJJ - assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), - 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); + assertSet(RUN, 6, + Arrays.asList(new Stone(1, RED), new Stone(RED), 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), @@ -73,9 +85,8 @@ public class StoneSetTest { // ZZJJ assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(2, 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)), - defaultSettings); + assertSet(GROUP, 4, Arrays.asList(new Stone(1, 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)), defaultSettings); @@ -97,62 +108,100 @@ public class StoneSetTest { assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(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); + 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)), 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)), - defaultSettings); - assertSet(GROUP, 6, Arrays.asList(new Stone(1, RED), - new Stone(1, GREEN), new Stone(1, GRAY), new Stone(1, BLACK), - new Stone(1, BLUE), new Stone(1, ORANGE)), moreColorSettings); + assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), 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)), defaultSettings); + assertSet(GROUP, 6, Arrays.asList(new Stone(1, RED), new Stone(1, GREEN), + new Stone(1, GRAY), 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)), 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)), + assertSet(RUN, 6, + Arrays.asList(new Stone(1, RED), new Stone(2, RED), new Stone(3, RED)), defaultSettings); - assertSet(RUN, 42, Arrays.asList(new Stone(13, RED), - new Stone(14, RED), new Stone(15, RED)), higherValueSettings); + 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)), defaultSettings); + assertSet(RUN, 42, Arrays.asList(new Stone(13, RED), new Stone(14, RED), + new Stone(15, RED)), higherValueSettings); } /** */ @Test public void singleJoker() { // ZJZ - assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), new Stone(BLACK), - new Stone(1, BLACK)), defaultSettings); - assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), - new Stone(3, RED)), defaultSettings); + assertSet( + GROUP, + 3, + Arrays.asList(new Stone(1, RED), new Stone(BLACK), new Stone(1, BLACK)), + defaultSettings); + assertSet(RUN, 6, + Arrays.asList(new Stone(1, RED), new Stone(RED), new Stone(3, RED)), + defaultSettings); // JZZ - assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, RED), - new Stone(1, BLACK)), defaultSettings); - assertSet(RUN, 6, Arrays.asList(new Stone(RED), new Stone(2, RED), - new Stone(3, RED)), defaultSettings); + assertSet(GROUP, 3, + Arrays.asList(new Stone(RED), new Stone(1, RED), new Stone(1, BLACK)), + defaultSettings); + assertSet(RUN, 6, + Arrays.asList(new Stone(RED), new Stone(2, RED), new Stone(3, RED)), + defaultSettings); // ZZJ - assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), - new Stone(1, BLACK), new Stone(BLACK)), defaultSettings); - assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), - new Stone(RED)), defaultSettings); - assertSet(RUN, 39, Arrays.asList(new Stone(12, RED), - new Stone(13, RED), new Stone(RED)), higherValueSettings); + assertSet( + GROUP, + 3, + Arrays.asList(new Stone(1, RED), new Stone(1, BLACK), new Stone(BLACK)), + defaultSettings); + assertSet(RUN, 6, + Arrays.asList(new Stone(1, RED), new Stone(2, RED), new Stone(RED)), + defaultSettings); + assertSet(RUN, 39, + Arrays.asList(new Stone(12, RED), new Stone(13, RED), new Stone(RED)), + higherValueSettings); + } + + @Test + public void noLimitsTest() { + assertSet(RUN, 16, + Arrays.asList(new Stone(RED), new Stone(1, RED), new Stone(2, RED)), + noLimitsSettings); + assertSet(RUN, 26, + Arrays.asList(new Stone(12, RED), new Stone(13, RED), new Stone(RED)), + noLimitsSettings); + assertSet(RUN, 20, + Arrays.asList(new Stone(9, RED), new Stone(10, RED), new Stone(RED)), + noLimitsLowerValueSettings); + assertSet(RUN, 28, Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(1, RED), new Stone(2, RED)), noLimitsSettings); + assertSet(RUN, 26, Arrays.asList(new Stone(12, RED), new Stone(13, RED), + new Stone(1, RED)), noLimitsSettings); + assertSet( + RUN, + 16, + Arrays.asList(new Stone(13, RED), new Stone(1, RED), new Stone(2, RED)), + noLimitsSettings); + + assertSet(INVALID, 0, + Arrays.asList(new Stone(13, RED), new Stone(RED), new Stone(1, RED)), + noLimitsSettings); } // invalid @@ -162,65 +211,87 @@ public class StoneSetTest { 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, AQUA), new Stone( - BLACK), new Stone(RED)), moreColorSettings); + 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, AQUA), 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)), defaultSettings); - assertSet(INVALID, 0, Arrays.asList(new Stone(12, RED), new Stone(13, - 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(1, RED), new Stone(2, RED)), + defaultSettings); + assertSet(INVALID, 0, + Arrays.asList(new Stone(12, RED), new Stone(13, 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)), defaultSettings); + assertSet(INVALID, 0, Arrays.asList(new Stone(12, RED), new Stone(13, RED), + new Stone(1, RED)), defaultSettings); + assertSet( + INVALID, + 0, + Arrays.asList(new Stone(13, 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)), 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)), 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, GRAY), new Stone(1, ORANGE), new Stone( - 1, AQUA), new Stone(RED)), moreColorSettings); + assertSet( + INVALID, + 0, + Arrays.asList(new Stone(1, RED), 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)), + 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, GRAY), new Stone(1, ORANGE), new Stone(1, AQUA), + 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)), defaultSettings); - assertSet(INVALID, 0, Arrays.asList(new Stone(4, 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)), defaultSettings); + assertSet(INVALID, 0, + Arrays.asList(new Stone(4, 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)), + defaultSettings); + assertSet(INVALID, 0, + Arrays.asList(new Stone(4, RED), new Stone(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)), defaultSettings); - assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), new Stone(5, - 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), new Stone(7, RED)), + defaultSettings); + assertSet( + INVALID, + 0, + Arrays.asList(new Stone(4, RED), new Stone(5, BLUE), new Stone(6, RED)), + defaultSettings); + assertSet(INVALID, 0, 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)), defaultSettings); - assertSet(INVALID, 0, Arrays.asList(new Stone(4, BLUE), new Stone(5, - 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)), defaultSettings); + assertSet(INVALID, 0, Arrays.asList(new Stone(12, ORANGE), new Stone(12, + BLACK), new Stone(7, BLUE)), defaultSettings); } /** */ @@ -231,12 +302,11 @@ public class StoneSetTest { 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)), + 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); } /** */ |