summaryrefslogtreecommitdiffstats
path: root/test/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'test/jrummikub')
-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.*;