summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBennet Gerlach <bennet_gerlach@web.de>2011-05-09 22:33:34 +0200
committerBennet Gerlach <bennet_gerlach@web.de>2011-05-09 22:33:34 +0200
commit9b307f18448e999610db82b00250f1e7d319a45c (patch)
treee309c96e51eaccbfafaf1970c4853c60bf6f44ab
parent5b0aed8fd0615604e0d9e04977c5282e746207ee (diff)
downloadJRummikub-9b307f18448e999610db82b00250f1e7d319a45c.tar
JRummikub-9b307f18448e999610db82b00250f1e7d319a45c.zip
Added edge tests to hand test
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@200 72836036-5685-4462-b002-a69064685172
-rw-r--r--test/jrummikub/model/HandTest.java56
1 files changed, 54 insertions, 2 deletions
diff --git a/test/jrummikub/model/HandTest.java b/test/jrummikub/model/HandTest.java
index 25a9c18..ec619d2 100644
--- a/test/jrummikub/model/HandTest.java
+++ b/test/jrummikub/model/HandTest.java
@@ -1,9 +1,10 @@
package jrummikub.model;
+import static jrummikub.model.StoneColor.*;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Before;
import org.junit.Test;
-import static jrummikub.model.StoneColor.*;
-import static org.junit.Assert.*;
public class HandTest {
@@ -28,4 +29,55 @@ public class HandTest {
assertEquals(new Position(3.5f, 0), hand.getPosition(stone2));
assertEquals(new Position(2.5f, 0), hand.getPosition(stone3));
}
+
+ @Test
+ public void testSingleEdgeDrop() {
+ Stone stone1 = new Stone(2, RED);
+ Stone stone2 = new Stone(4, RED);
+
+ hand.drop(stone1, new Position(0, 0));
+ hand.drop(stone2, new Position(0.5f, 0));
+
+ assertEquals(new Position(0, 0), hand.getPosition(stone1));
+ assertEquals(new Position(1, 0), hand.getPosition(stone2));
+ }
+
+ @Test
+ public void testNearEdgeDrop() {
+ Stone stone1 = new Stone(2, RED);
+ Stone stone2 = new Stone(4, RED);
+
+ hand.drop(stone1, new Position(0.25f, 0));
+ hand.drop(stone2, new Position(0.5f, 0));
+
+ assertEquals(new Position(0, 0), hand.getPosition(stone1));
+ assertEquals(new Position(1, 0), hand.getPosition(stone2));
+ }
+
+ @Test
+ public void testNearEdgeMiddleDrop() {
+ Stone stone1 = new Stone(1, RED);
+ Stone stone2 = new Stone(5, RED);
+ Stone stone3 = new Stone(2, RED);
+
+ hand.drop(stone1, new Position(0.25f, 0));
+ hand.drop(stone2, new Position(1.25f, 0));
+ hand.drop(stone3, new Position(0.5f, 0));
+
+ assertEquals(new Position(0, 0), hand.getPosition(stone1));
+ assertEquals(new Position(2, 0), hand.getPosition(stone2));
+ assertEquals(new Position(1, 0), hand.getPosition(stone3));
+ }
+
+ @Test
+ public void testNearRightEdgeDrop() {
+ Stone stone1 = new Stone(2, BLUE);
+ Stone stone2 = new Stone(4, BLUE);
+
+ hand.drop(stone1, new Position(12.75f, 0));
+ hand.drop(stone2, new Position(12.5f, 0));
+
+ assertEquals(new Position(13, 0), hand.getPosition(stone1));
+ assertEquals(new Position(12, 0), hand.getPosition(stone2));
+ }
}