summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-01 00:13:22 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-01 00:13:22 +0200
commitb8fa08c9bb502b08e643c84c656f31cf0ad23f4d (patch)
tree036f3672ba4fc22634bc432d9c3a9ea2e6cda9e3 /test
parentd262d91b076cbaa322d49818476b251c06cee42e (diff)
downloadJRummikub-b8fa08c9bb502b08e643c84c656f31cf0ad23f4d.tar
JRummikub-b8fa08c9bb502b08e643c84c656f31cf0ad23f4d.zip
StoneSetTest fertig
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@42 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/model/StoneSetTest.java99
-rw-r--r--test/jrummikub/model/StoneTrayTest.java1
2 files changed, 88 insertions, 12 deletions
diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java
index 259c788..d929783 100644
--- a/test/jrummikub/model/StoneSetTest.java
+++ b/test/jrummikub/model/StoneSetTest.java
@@ -1,6 +1,7 @@
package jrummikub.model;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import jrummikub.util.Pair;
@@ -11,6 +12,82 @@ import static org.junit.Assert.*;
public class StoneSetTest {
+ // Is Valid-Test
+ // valid
+ public void assertSet(boolean valid, List<Stone> stones) {
+ StoneSet set = new StoneSet(stones);
+ assertTrue(valid == set.isValid());
+ }
+
+ @Test
+ public void doubleJoker() {
+ assertSet(true, Arrays.asList(new Stone(RED), new Stone(BLACK),
+ new Stone(1, BLACK)));
+ }
+
+ @Test
+ public void groups() {
+ assertSet(true, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK),
+ new Stone(1, BLUE)));
+ assertSet(true, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK),
+ new Stone(1, BLUE), new Stone(1, ORANGE)));
+ }
+
+ @Test
+ public void runs() {
+ assertSet(true, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
+ new Stone(3, RED)));
+ assertSet(true, Arrays.asList(new Stone(4, BLUE), new Stone(5, BLUE),
+ new Stone(6, BLUE)));
+ }
+
+ @Test
+ public void singleJoker() {
+ assertSet(true, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK),
+ new Stone(RED)));
+ assertSet(true, Arrays.asList(new Stone(2, RED), new Stone(3, RED),
+ new Stone(BLACK)));
+ }
+
+ // invalid
+
+ @Test
+ public void outOfBounds() {
+ assertSet(false, Arrays.asList(new Stone(RED), new Stone(1, RED),
+ new Stone(2, RED)));
+ assertSet(false, Arrays.asList(new Stone(12, RED), new Stone(13, RED),
+ new Stone(RED)));
+ assertSet(false, Arrays.asList(new Stone(RED), new Stone(BLACK),
+ new Stone(1, RED), new Stone(2, RED)));
+ }
+ @Test
+ public void sameColor() {
+ assertSet(false, Arrays.asList(new Stone(1, RED), new Stone(1, RED),
+ new Stone(1, BLUE)));
+ assertSet(false, 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(false, Arrays.asList(new Stone(4, RED), new Stone(6, RED),
+ new Stone(5, RED)));
+ assertSet(false, Arrays.asList(new Stone(4, RED), new Stone(6, RED),
+ new Stone(RED)));
+ assertSet(false, Arrays.asList(new Stone(4, RED), new Stone(RED),
+ new Stone(5, RED)));
+ }
+
+ @Test
+ public void otherInvalid() {
+
+ assertSet(false, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
+ new Stone(7, RED)));
+ assertSet(false, Arrays.asList(new Stone(4, RED), new Stone(5, BLUE),
+ new Stone(6, RED)));
+ assertSet(false, Arrays.asList(new Stone(4, RED), new Stone(5, RED)));
+
+ }
// invalid Split
@Test(expected = AssertionError.class)
public void testSplitInvalidLow() {
@@ -63,18 +140,18 @@ public class StoneSetTest {
assertSame(testSet.get(2), joinedSet.get(2));
assertSame(secondSet.get(0), joinedSet.get(3));
}
-
- //iterator
+
+ // iterator
@Test
public void testIterator() {
- StoneSet testSet = createTestSet();
- int i = 0;
-
- for(Stone stone : testSet) {
- assertSame(stone,testSet.get(i));
- i++;
- }
-
- assertEquals(i, testSet.size());
+ StoneSet testSet = createTestSet();
+ int i = 0;
+
+ for (Stone stone : testSet) {
+ assertSame(stone, testSet.get(i));
+ i++;
+ }
+
+ assertEquals(i, testSet.size());
}
}
diff --git a/test/jrummikub/model/StoneTrayTest.java b/test/jrummikub/model/StoneTrayTest.java
index 3fd8b22..57f3d1a 100644
--- a/test/jrummikub/model/StoneTrayTest.java
+++ b/test/jrummikub/model/StoneTrayTest.java
@@ -4,7 +4,6 @@ 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.*;