From f7aace72346b32af6b6aeb7e650d762ec263ff2f Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Mon, 16 May 2011 20:54:37 +0200 Subject: =?UTF-8?q?Tests=20und=20imlementierung=20f=C3=BCr=20Wert=20von=20?= =?UTF-8?q?Sets=20bestimmen,=20fertig=20und=20getestet?= 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@242 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/model/GameStateTest.java | 1 + test/jrummikub/model/StoneSetTest.java | 134 ++++++++++++++++++++++---------- 2 files changed, 95 insertions(+), 40 deletions(-) (limited to 'test/jrummikub/model') diff --git a/test/jrummikub/model/GameStateTest.java b/test/jrummikub/model/GameStateTest.java index 5681904..5a55aef 100644 --- a/test/jrummikub/model/GameStateTest.java +++ b/test/jrummikub/model/GameStateTest.java @@ -31,4 +31,5 @@ public class GameStateTest { testGame.nextPlayer(); assertSame(Color.red, testGame.getActivePlayer().getColor()); } + } diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java index e2962d4..4b83c94 100644 --- a/test/jrummikub/model/StoneSetTest.java +++ b/test/jrummikub/model/StoneSetTest.java @@ -16,92 +16,146 @@ import static org.junit.Assert.*; */ public class StoneSetTest { - private void assertSet(StoneSet.Type expectedType, List stones) { + private void assertSet(StoneSet.Type expectedType, Integer expectedValue, + List stones) { StoneSet set = new StoneSet(stones); - assertSame(expectedType, set.classify()); + assertSame(expectedType, set.classify().getFirst()); + assertEquals(expectedValue, set.classify().getSecond()); } - // valid + // valid+point count /** */ @Test public void doubleJoker() { - assertSet(GROUP, - Arrays.asList(new Stone(RED), new Stone(BLACK), new Stone(1, BLACK))); + // 3 Stones + // JJZ + assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(1, BLACK))); + // JZJ + assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, BLACK), + new Stone(BLACK))); + // ZJJ + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), + new Stone(BLACK))); + // 4 Stones + // JJZZ + assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(1, BLACK), new Stone(1, RED))); + assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(3, RED), new Stone(4, RED))); + // ZZJJ + assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(2, RED), + new Stone(BLACK), new Stone(RED))); + assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), + new Stone(1, BLACK), new Stone(BLACK), new Stone(RED))); + // ZJZJ + assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), new Stone(BLACK), + new Stone(1, BLACK), new Stone(RED))); + assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(RED), + new Stone(3, RED), new Stone(BLACK))); + // JZJZ + assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(1, BLACK), + new Stone(BLACK), new Stone(1, RED))); + assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(2, RED), + new Stone(BLACK), new Stone(4, RED))); + // JZZJ + assertSet(GROUP, 4, Arrays.asList(new Stone(RED), new Stone(1, BLACK), + new Stone(1, RED), new Stone(BLACK))); + assertSet(RUN, 10, Arrays.asList(new Stone(RED), new Stone(2, RED), + new Stone(3, RED), new Stone(BLACK))); + // ZJJZ + assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), new Stone(BLACK), + new Stone(RED), new Stone(1, BLACK))); + assertSet(RUN, 10, Arrays.asList(new Stone(1, RED), new Stone(RED), + new Stone(BLACK), new Stone(4, RED))); } /** */ @Test public void groups() { - assertSet(GROUP, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK), - new Stone(1, BLUE))); - assertSet(GROUP, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK), - new Stone(1, BLUE), new Stone(1, ORANGE))); + assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), + new Stone(1, BLACK), new Stone(1, BLUE))); + assertSet(GROUP, 4, Arrays.asList(new Stone(1, RED), + new Stone(1, BLACK), new Stone(1, BLUE), new Stone(1, ORANGE))); } /** */ @Test public void runs() { - assertSet(RUN, - Arrays.asList(new Stone(1, RED), new Stone(2, RED), new Stone(3, RED))); - assertSet(RUN, Arrays.asList(new Stone(4, BLUE), new Stone(5, BLUE), - new Stone(6, BLUE))); + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), + new Stone(3, RED))); + assertSet(RUN, 22, Arrays.asList(new Stone(4, BLUE), new Stone(5, BLUE), + new Stone(6, BLUE), new Stone(7, BLUE))); } /** */ @Test public void singleJoker() { - assertSet(GROUP, - Arrays.asList(new Stone(1, RED), new Stone(1, BLACK), new Stone(RED))); - assertSet(RUN, - Arrays.asList(new Stone(2, RED), new Stone(3, RED), new Stone(BLACK))); + // ZJZ + assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), new Stone(BLACK), + new Stone(1, BLACK))); + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(RED), + new Stone(3, RED))); + // JZZ + assertSet(GROUP, 3, Arrays.asList(new Stone(RED), new Stone(1, RED), + new Stone(1, BLACK))); + assertSet(RUN, 6, Arrays.asList(new Stone(RED), new Stone(2, RED), + new Stone(3, RED))); + // ZZJ + assertSet(GROUP, 3, Arrays.asList(new Stone(1, RED), + new Stone(1, BLACK), new Stone(BLACK))); + assertSet(RUN, 6, Arrays.asList(new Stone(1, RED), new Stone(2, RED), + new Stone(RED))); } // invalid /** */ @Test public void outOfBounds() { - assertSet(INVALID, Arrays.asList(new Stone(RED), new Stone(1, RED), + assertSet(INVALID, 0, Arrays.asList(new Stone(RED), new Stone(1, RED), new Stone(2, RED))); - assertSet(INVALID, Arrays.asList(new Stone(12, RED), - new Stone(13, RED), new Stone(RED))); - assertSet(INVALID, Arrays.asList(new Stone(RED), new Stone(BLACK), + assertSet(INVALID, 0, Arrays.asList(new Stone(12, RED), new Stone(13, + RED), new Stone(RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(RED), new Stone(BLACK), new Stone(1, RED), new Stone(2, RED))); } /** */ @Test public void sameColor() { - assertSet(INVALID, - Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, BLUE))); - assertSet(INVALID, Arrays.asList(new Stone(1, RED), new Stone(1, BLUE), - new Stone(1, BLACK), new Stone(1, ORANGE), new Stone(RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), + new Stone(1, RED), new Stone(1, BLUE))); + assertSet(INVALID, 0, Arrays.asList(new Stone(1, RED), new Stone(1, + BLUE), new Stone(1, BLACK), new Stone(1, ORANGE), + new Stone(RED))); } /** */ @Test public void incorrectOrder() { - assertSet(INVALID, - Arrays.asList(new Stone(4, RED), new Stone(6, RED), new Stone(5, RED))); - assertSet(INVALID, - Arrays.asList(new Stone(4, RED), new Stone(6, RED), new Stone(RED))); - assertSet(INVALID, - Arrays.asList(new Stone(4, RED), new Stone(RED), new Stone(5, RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), + new Stone(6, RED), new Stone(5, RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), + new Stone(6, RED), new Stone(RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), new Stone(RED), + new Stone(5, RED))); } /** */ @Test public void otherInvalid() { - assertSet(INVALID, - Arrays.asList(new Stone(4, RED), new Stone(5, RED), new Stone(7, RED))); - assertSet(INVALID, - Arrays.asList(new Stone(4, RED), new Stone(5, BLUE), new Stone(6, RED))); - assertSet(INVALID, Arrays.asList(new Stone(4, RED), new Stone(5, RED))); - assertSet(INVALID, - Arrays.asList(new Stone(4, BLUE), new Stone(5, RED), new Stone(6, RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), + new Stone(5, RED), new Stone(7, RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, RED), new Stone(5, + BLUE), new Stone(6, RED))); + assertSet(INVALID, 0, + Arrays.asList(new Stone(4, RED), new Stone(5, RED))); + assertSet(INVALID, 0, Arrays.asList(new Stone(4, BLUE), new Stone(5, + RED), new Stone(6, RED))); // Regression test: - assertSet(INVALID, Arrays.asList(new Stone(12, ORANGE), new Stone(12, - BLACK), new Stone(7, BLUE))); + assertSet(INVALID, 0, Arrays.asList(new Stone(12, ORANGE), new Stone( + 12, BLACK), new Stone(7, BLUE))); } // invalid Split -- cgit v1.2.3