summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/model
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-10 03:54:48 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-10 03:54:48 +0200
commit3b49b2053e9f9d26b73db0ffc8380a60706ee095 (patch)
tree9678d5abb4af070bbf0fd89c684e91f5fd472c31 /test/jrummikub/model
parent4a860e53cf6f2f97f18785673399498609e6504b (diff)
downloadJRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.tar
JRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.zip
Added all missing comments
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@213 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/model')
-rw-r--r--test/jrummikub/model/GameStateTest.java6
-rw-r--r--test/jrummikub/model/HandTest.java12
-rw-r--r--test/jrummikub/model/StoneHeapTest.java20
-rw-r--r--test/jrummikub/model/StoneSetTest.java34
-rw-r--r--test/jrummikub/model/StoneTrayTest.java18
-rw-r--r--test/jrummikub/model/TableTest.java29
6 files changed, 92 insertions, 27 deletions
diff --git a/test/jrummikub/model/GameStateTest.java b/test/jrummikub/model/GameStateTest.java
index e1de06c..5681904 100644
--- a/test/jrummikub/model/GameStateTest.java
+++ b/test/jrummikub/model/GameStateTest.java
@@ -6,15 +6,19 @@ import java.awt.Color;
import org.junit.Before;
import org.junit.Test;
-
+/**
+ * Test class for {@link GameState}
+ */
public class GameStateTest {
private IGameState testGame;
+ /** */
@Before
public void createGame() {
testGame = new GameState();
}
+ /** */
@Test
public void nextActiveTest() {
// All there?
diff --git a/test/jrummikub/model/HandTest.java b/test/jrummikub/model/HandTest.java
index d913caf..46aa978 100644
--- a/test/jrummikub/model/HandTest.java
+++ b/test/jrummikub/model/HandTest.java
@@ -5,16 +5,20 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
-
+/**
+ * Test class for {@link Hand}
+ */
public class HandTest {
Hand hand;
+ /** */
@Before
public void setUp() {
hand = new Hand();
}
+ /** */
@Test
public void testSimpleDrop() {
Stone stone1 = new Stone(1, RED);
@@ -30,6 +34,7 @@ public class HandTest {
assertEquals(new Position(2.5f, 0), hand.getPosition(stone3));
}
+ /** */
@Test
public void testSingleEdgeDrop() {
Stone stone1 = new Stone(2, RED);
@@ -42,6 +47,7 @@ public class HandTest {
assertEquals(new Position(1, 0), hand.getPosition(stone2));
}
+ /** */
@Test
public void testNearEdgeDrop() {
Stone stone1 = new Stone(2, RED);
@@ -54,6 +60,7 @@ public class HandTest {
assertEquals(new Position(1, 0), hand.getPosition(stone2));
}
+ /** */
@Test
public void testNearEdgeMiddleDrop() {
Stone stone1 = new Stone(1, RED);
@@ -69,6 +76,7 @@ public class HandTest {
assertEquals(new Position(1, 0), hand.getPosition(stone3));
}
+ /** */
@Test
public void testNearRightEdgeDrop() {
Stone stone1 = new Stone(2, BLUE);
@@ -81,6 +89,7 @@ public class HandTest {
assertEquals(new Position(12, 1), hand.getPosition(stone2));
}
+ /** */
@Test
public void testRightWrapDrop() {
Stone stone1 = new Stone(12, ORANGE);
@@ -93,6 +102,7 @@ public class HandTest {
assertEquals(new Position(12.5f, 0), hand.getPosition(stone2));
}
+ /** */
@Test
public void testLeftWrapDrop() {
Stone stone1 = new Stone(1, ORANGE);
diff --git a/test/jrummikub/model/StoneHeapTest.java b/test/jrummikub/model/StoneHeapTest.java
index 01f5da3..9fd375a 100644
--- a/test/jrummikub/model/StoneHeapTest.java
+++ b/test/jrummikub/model/StoneHeapTest.java
@@ -8,21 +8,29 @@ import java.util.Map;
import org.junit.*;
import static org.junit.Assert.*;
+/**
+ * Tests for {@link StoneHeap}
+ */
public class StoneHeapTest {
private StoneHeap testHeap;
+ /** */
@Before
public void createHeap() {
testHeap = new StoneHeap();
}
- // Is the right number of Stones in heap?
+ /**
+ * Is the right number of Stones in heap?
+ */
@Test
public void fullStoneHeap() {
assertEquals(106, testHeap.heap.size());
}
- // Enough stones of each color in heap?
+ /**
+ * Enough stones of each color in heap?
+ */
@Test
public void fullColor() {
Map<StoneColor, Integer> counters = new HashMap<StoneColor, Integer>();
@@ -40,7 +48,9 @@ public class StoneHeapTest {
}
}
- // Enough Jokers?
+ /**
+ * Enough Jokers?
+ */
@Test
public void fullJoker() {
int countJoker = 0;
@@ -51,14 +61,14 @@ public class StoneHeapTest {
assertEquals(2, countJoker);
}
- // Draw Stone Test
+ /** */
@Test
public void drawStoneTest() {
assertNotNull(testHeap.drawStone());
assertEquals(105, testHeap.heap.size());
}
- // Draw Stones Test
+ /** */
@Test
public void drawStonesTest() {
List<Stone> testStones = testHeap.drawStones(5);
diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java
index b98d3d8..2575f22 100644
--- a/test/jrummikub/model/StoneSetTest.java
+++ b/test/jrummikub/model/StoneSetTest.java
@@ -11,21 +11,25 @@ import static jrummikub.model.StoneSet.Type.*;
import org.junit.*;
import static org.junit.Assert.*;
+/**
+ * Tests for {@link StoneSet}
+ */
public class StoneSetTest {
- // Is Valid-Test
- // valid
- public void assertSet(StoneSet.Type expectedType, List<Stone> stones) {
+ private void assertSet(StoneSet.Type expectedType, List<Stone> stones) {
StoneSet set = new StoneSet(stones);
assertSame(expectedType, set.classify());
}
+ // valid
+ /** */
@Test
public void doubleJoker() {
assertSet(GROUP,
Arrays.asList(new Stone(RED), new Stone(BLACK), new Stone(1, BLACK)));
}
+ /** */
@Test
public void groups() {
assertSet(GROUP, Arrays.asList(new Stone(1, RED), new Stone(1, BLACK),
@@ -34,6 +38,7 @@ public class StoneSetTest {
new Stone(1, BLUE), new Stone(1, ORANGE)));
}
+ /** */
@Test
public void runs() {
assertSet(RUN,
@@ -42,6 +47,7 @@ public class StoneSetTest {
new Stone(6, BLUE)));
}
+ /** */
@Test
public void singleJoker() {
assertSet(GROUP,
@@ -51,17 +57,18 @@ public class StoneSetTest {
}
// invalid
-
+ /** */
@Test
public void outOfBounds() {
- assertSet(INVALID,
- 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(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),
new Stone(1, RED), new Stone(2, RED)));
}
+ /** */
@Test
public void sameColor() {
assertSet(INVALID,
@@ -70,6 +77,7 @@ public class StoneSetTest {
new Stone(1, BLACK), new Stone(1, ORANGE), new Stone(RED)));
}
+ /** */
@Test
public void incorrectOrder() {
assertSet(INVALID,
@@ -80,6 +88,7 @@ public class StoneSetTest {
Arrays.asList(new Stone(4, RED), new Stone(RED), new Stone(5, RED)));
}
+ /** */
@Test
public void otherInvalid() {
@@ -91,11 +100,12 @@ public class StoneSetTest {
assertSet(INVALID,
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, Arrays.asList(new Stone(12, ORANGE), new Stone(12,
+ BLACK), new Stone(7, BLUE)));
}
// invalid Split
+ /** */
@Test
public void testSplitInvalidLow() {
StoneSet testSet = createTestSet();
@@ -103,6 +113,7 @@ public class StoneSetTest {
}
+ /** */
@Test
public void testSplitInvalidHigh() {
StoneSet testSet = createTestSet();
@@ -110,6 +121,7 @@ public class StoneSetTest {
}
// valid Split
+ /** */
@Test
public void testSplitValid() {
StoneSet testSet = createTestSet();
@@ -133,6 +145,7 @@ public class StoneSetTest {
}
// join
+ /** */
@Test
public void testJoin() {
StoneSet testSet = createTestSet();
@@ -148,6 +161,7 @@ public class StoneSetTest {
}
// iterator
+ /** */
@Test
public void testIterator() {
StoneSet testSet = createTestSet();
diff --git a/test/jrummikub/model/StoneTrayTest.java b/test/jrummikub/model/StoneTrayTest.java
index 1c8b241..84fc799 100644
--- a/test/jrummikub/model/StoneTrayTest.java
+++ b/test/jrummikub/model/StoneTrayTest.java
@@ -7,7 +7,9 @@ import jrummikub.util.Pair;
import org.junit.*;
import static org.junit.Assert.*;
-
+/**
+ * Tests for {@link StoneTray}
+ */
public class StoneTrayTest {
class Thing implements Sizeable {
private float width;
@@ -30,12 +32,13 @@ public class StoneTrayTest {
}
private StoneTray<Thing> testTray;
-
+ /** */
@Before
public void createTray() {
testTray = new StoneTray<Thing>();
}
+ /** */
@Test
public void testDrop() {
Thing firstThing = new Thing(3, 4);
@@ -50,6 +53,7 @@ public class StoneTrayTest {
assertEquals(8.5, secondPosition.getY(), 0.00001);
}
+ /** */
@Test
public void testDropNull() {
testTray.drop(null, new Position(0, 0));
@@ -57,6 +61,7 @@ public class StoneTrayTest {
}
// Leftshift
+ /** */
@Test
public void testLeftDrop() {
Thing firstThing = new Thing(5, 5);
@@ -72,6 +77,7 @@ public class StoneTrayTest {
}
// Rightshift
+ /** */
@Test
public void testRightDrop() {
Thing firstThing = new Thing(5, 5);
@@ -87,6 +93,7 @@ public class StoneTrayTest {
}
// Upshift
+ /** */
@Test
public void testUpDrop() {
Thing firstThing = new Thing(5, 5);
@@ -102,6 +109,7 @@ public class StoneTrayTest {
}
// Downshift
+ /** */
@Test
public void testDownDrop() {
Thing firstThing = new Thing(5, 5);
@@ -116,6 +124,7 @@ public class StoneTrayTest {
assertEquals(-2, secondPosition.getY(), 0.00001);
}
+ /** */
@Test
public void testDoubleShift() {
Thing firstThing = new Thing(5, 5);
@@ -137,6 +146,7 @@ public class StoneTrayTest {
assertEquals(1, thirdPosition.getY(), 0.00001);
}
+ /** */
@Test
public void testWrongPickUp() {
Thing firstThing = new Thing(5, 5);
@@ -145,6 +155,7 @@ public class StoneTrayTest {
assertNull(testTray.pickUp(testPosition));
}
+ /** */
@Test
public void testPickUpByObject() {
Thing firstThing = new Thing(5, 5);
@@ -158,6 +169,7 @@ public class StoneTrayTest {
assertTrue(testTray.iterator().hasNext());
}
+ /** */
@Test
public void testRightPickUp() {
Thing firstThing = new Thing(5, 5);
@@ -169,6 +181,7 @@ public class StoneTrayTest {
assertNull(testTray.pickUp(testPosition));
}
+ /** */
@Test
public void testIterate() {
List<Thing> testThings = new ArrayList<Thing>();
@@ -191,6 +204,7 @@ public class StoneTrayTest {
assertTrue(testPositions.isEmpty());
}
+ /** */
@Test
public void testClone() {
Thing firstThing = new Thing(5, 5);
diff --git a/test/jrummikub/model/TableTest.java b/test/jrummikub/model/TableTest.java
index a806e14..0d53aed 100644
--- a/test/jrummikub/model/TableTest.java
+++ b/test/jrummikub/model/TableTest.java
@@ -12,22 +12,28 @@ import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
+/**
+ * Tests for {@link Table}
+ */
public class TableTest {
Table testTable;
+ /** */
@Before
public void setup() {
testTable = new Table();
}
+ /** */
@Test
public void testIsValid() {
testTable.drop(
- new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK), new Stone(
- 1, BLACK))), new Position(0, 0));
+ new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK),
+ new Stone(1, BLACK))), new Position(0, 0));
testTable.drop(
- new StoneSet(Arrays.asList(new Stone(1, RED), new Stone(2, RED),
- new Stone(3, RED))), new Position(0, 0));
+ new StoneSet(Arrays.asList(new Stone(1, RED),
+ new Stone(2, RED), new Stone(3, RED))), new Position(0,
+ 0));
assertTrue(testTable.isValid());
testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))),
@@ -35,18 +41,20 @@ public class TableTest {
assertFalse(testTable.isValid());
}
+ /** */
@Test
public void testEmptyIsValid() {
assertTrue(testTable.isValid());
}
+ /** */
@Test
@SuppressWarnings("unused")
public void testPickUpStoneGroup() {
Stone targetStone = new Stone(BLACK);
testTable.drop(
- new StoneSet(Arrays.asList(new Stone(RED), targetStone, new Stone(1,
- BLACK))), new Position(0, 0));
+ new StoneSet(Arrays.asList(new Stone(RED), targetStone,
+ new Stone(1, BLACK))), new Position(0, 0));
assertTrue(testTable.isValid());
testTable.pickUpStone(targetStone);
assertFalse(testTable.isValid());
@@ -58,6 +66,7 @@ public class TableTest {
assertEquals(1, counter);
}
+ /** */
@Test
public void testPickLonelyStone() {
Stone targetStone = new Stone(BLACK);
@@ -66,6 +75,7 @@ public class TableTest {
assertEquals(0, testTable.getSize());
}
+ /** */
@Test
public void testPickStoneFromEmptyTable() {
Stone targetStone = new Stone(BLACK);
@@ -73,6 +83,7 @@ public class TableTest {
assertEquals(0, testTable.getSize());
}
+ /** */
@Test
public void testPickNonexistentStone() {
Stone targetStone = new Stone(BLACK);
@@ -84,13 +95,14 @@ public class TableTest {
assertSame(testTable.findStoneSet(droppedStone), set);
}
+ /** */
@Test
@SuppressWarnings("unused")
public void testPickUpStoneRun() {
Stone targetStone = new Stone(BLACK);
testTable.drop(
- new StoneSet(Arrays.asList(new Stone(1, RED), targetStone, new Stone(3,
- RED))), new Position(0, 0));
+ new StoneSet(Arrays.asList(new Stone(1, RED), targetStone,
+ new Stone(3, RED))), new Position(0, 0));
assertTrue(testTable.isValid());
testTable.pickUpStone(targetStone);
assertFalse(testTable.isValid());
@@ -102,6 +114,7 @@ public class TableTest {
assertEquals(2, counter);
}
+ /** */
@Test
public void testFindSet() {
Stone targetStone = new Stone(BLACK);