diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-04-30 17:23:57 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-04-30 17:23:57 +0200 |
commit | 5440eaba77a77de9ff7ff502e2281b6ad6a5b92e (patch) | |
tree | a84386ba13851d71de23b2aa1e55ae857adede79 /test/jrummikub/model | |
parent | bc774c639bb7eef4d6af341012c6696e0bda2fcd (diff) | |
download | JRummikub-5440eaba77a77de9ff7ff502e2281b6ad6a5b92e.tar JRummikub-5440eaba77a77de9ff7ff502e2281b6ad6a5b92e.zip |
Test für Stone Set, ohne isValid
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@29 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/model')
-rw-r--r-- | test/jrummikub/model/StoneSetTest.java | 60 |
1 files changed, 60 insertions, 0 deletions
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<StoneSet, StoneSet> 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<Stone> stones = new ArrayList<Stone>(); + 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)); + } } |