From 5440eaba77a77de9ff7ff502e2281b6ad6a5b92e Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sat, 30 Apr 2011 17:23:57 +0200 Subject: =?UTF-8?q?Test=20f=C3=BCr=20Stone=20Set,=20ohne=20isValid?= 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@29 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/model/StoneSetTest.java | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'test/jrummikub/model') diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java index fc7ebda..c70dc59 100644 --- a/test/jrummikub/model/StoneSetTest.java +++ b/test/jrummikub/model/StoneSetTest.java @@ -1,6 +1,66 @@ package jrummikub.model; +import java.util.ArrayList; +import java.util.List; + +import jrummikub.util.Pair; +import static jrummikub.model.StoneColor.*; + +import org.junit.*; +import static org.junit.Assert.*; public class StoneSetTest { + // invalid Split + @Test(expected = AssertionError.class) + public void testSplitInvalidLow() { + StoneSet testSet = createTestSet(); + testSet.splitAt(0); + + } + + @Test(expected = AssertionError.class) + public void testSplitInvalidHigh() { + StoneSet testSet = createTestSet(); + testSet.splitAt(3); + + } + + // valid Split + @Test + public void testSplitValid() { + StoneSet testSet = createTestSet(); + Pair newSets = testSet.splitAt(1); + // Sets have right size + assertEquals(1, newSets.getFirst().size()); + assertEquals(2, newSets.getSecond().size()); + // Set have right Stones + assertSame(testSet.get(0), newSets.getFirst().get(0)); + assertSame(testSet.get(1), newSets.getSecond().get(0)); + assertSame(testSet.get(2), newSets.getSecond().get(1)); + } + + private StoneSet createTestSet() { + List stones = new ArrayList(); + stones.add(new Stone(1, BLUE, false)); + stones.add(new Stone(1, RED, false)); + stones.add(new Stone(1, BLACK, false)); + StoneSet testSet = new StoneSet(stones); + return testSet; + } + + // join + @Test + public void testJoin() { + StoneSet testSet = createTestSet(); + StoneSet secondSet = new StoneSet(new Stone(2, BLUE, false)); + StoneSet joinedSet = testSet.join(secondSet); + // Sets have right size + assertEquals(4, joinedSet.size()); + // Set have right Stones + assertSame(testSet.get(0), joinedSet.get(0)); + assertSame(testSet.get(1), joinedSet.get(1)); + assertSame(testSet.get(2), joinedSet.get(2)); + assertSame(secondSet.get(0), joinedSet.get(3)); + } } -- cgit v1.2.3