[Picross-commit] SF.net SVN: picross:[103] branches/engine_split
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2013-01-09 13:32:22
|
Revision: 103 http://picross.svn.sourceforge.net/picross/?rev=103&view=rev Author: yvan_norsa Date: 2013-01-09 13:32:12 +0000 (Wed, 09 Jan 2013) Log Message: ----------- split tests Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java branches/engine_split/test/picross/grid/ui/FillCommandTest.java branches/engine_split/test/picross/grid/ui/IGridMediatorStub.java branches/engine_split/test/picross/grid/ui/UIBoxTest.java Added Paths: ----------- branches/engine_split/engine/test/ branches/engine_split/engine/test/picross/ branches/engine_split/engine/test/picross/engine/ branches/engine_split/engine/test/picross/engine/game/ branches/engine_split/engine/test/picross/engine/grid/ branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java branches/engine_split/engine/test/picross/engine/grid/BoxTest.java branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java Removed Paths: ------------- branches/engine_split/test/picross/game/ branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java branches/engine_split/test/picross/grid/BoxTest.java branches/engine_split/test/picross/grid/CompletedHintsTest.java branches/engine_split/test/picross/grid/GridModelIntegrationTest.java branches/engine_split/test/picross/grid/GridModelTest.java Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/build.xml 2013-01-09 13:32:12 UTC (rev 103) @@ -17,6 +17,8 @@ value="engine/src" /> <property name="game.src.dir" value="src" /> + <property name="engine.test.dir" + value="engine/test" /> <property name="game.test.dir" value="test" /> @@ -70,8 +72,8 @@ <path id="classpath"> <pathelement location="${game.build.dir}" /> + <pathelement location="${engine.build.dir}" /> - <pathelement location="${engine.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${easymock.jar}" /> <pathelement location="${junit.jar}" /> @@ -104,7 +106,20 @@ </javac> </target> - <target name="compile-test" + <target name="engine-compile-test" + depends="engine-compile"> + <javac srcdir="${engine.test.dir}" + destdir="${engine.build.dir}" + deprecation="on" + debug="on" + optimize="off"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + + <target name="game-compile-test" depends="game-compile"> <javac srcdir="${game.test.dir}" destdir="${game.build.dir}" @@ -181,7 +196,10 @@ </target> <target name="test" - depends="dist,compile-test"> + depends="engine-test,game-test" /> + + <target name="engine-test" + depends="dist,engine-compile-test"> <junit filtertrace="off" showoutput="on" printsummary="withOutAndErr"> @@ -190,6 +208,26 @@ <batchtest fork="yes" filtertrace="on"> + <fileset dir="${engine.test.dir}"> + <include name="**/*Test.java" /> + <exclude name="**/Abstract*Test.java" /> + </fileset> + </batchtest> + + <classpath refid="classpath" /> + </junit> + </target> + + <target name="game-test" + depends="dist,game-compile-test"> + <junit filtertrace="off" + showoutput="on" + printsummary="withOutAndErr"> + <formatter type="plain" + usefile="false" /> + + <batchtest fork="yes" + filtertrace="on"> <fileset dir="${game.test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> Modified: branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-09 13:32:12 UTC (rev 103) @@ -34,7 +34,7 @@ package picross.engine; public final class PicrossLogHelper { - private static PicrossLogger logger; + private static PicrossLogger logger = new DefaultPicrossLogger(); public static PicrossLogger getLogger() { return PicrossLogHelper.logger; @@ -45,4 +45,21 @@ } private PicrossLogHelper() { } + + private static final class DefaultPicrossLogger implements PicrossLogger { + @Override + public void debug(String msg) { + System.out.println("DEBUG " + msg); + } + + @Override + public void info(String msg) { + System.out.println("INFO " + msg); + } + + @Override + public void error(String msg) { + System.out.println("ERROR " + msg); + } + } } Modified: branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java =================================================================== --- branches/engine_split/test/picross/game/random/RandomPicrossModelTest.java 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -31,14 +31,14 @@ */ -package picross.game.random; +package picross.engine.game.random; import org.apache.log4j.PropertyConfigurator; import org.junit.Test; -import picross.grid.AbstractPicrossGridTest; -import picross.grid.PicrossGrid; +import picross.engine.grid.AbstractPicrossGridTest; +import picross.engine.grid.PicrossGrid; /** * Test class for the random model. Modified: branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java =================================================================== --- branches/engine_split/test/picross/game/simple/XBMModelTest.java 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -31,7 +31,7 @@ */ -package picross.game.simple; +package picross.engine.game.simple; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -43,11 +43,12 @@ import org.junit.Test; import picross.Picross; -import picross.PicrossException; -import picross.grid.AbstractPicrossGridTest; -import picross.grid.PicrossGrid; +import picross.engine.PicrossException; +import picross.engine.grid.AbstractPicrossGridTest; +import picross.engine.grid.PicrossGrid; + /** * Unit tests for XBMModel. * Copied: branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java (from rev 101, branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,112 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.engine.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Abstract test class for the PicrossGrid interface. + * + * @author Y. Norsa + */ +public abstract class AbstractPicrossGridTest { + /*** Field ***/ + + /** The instance to test. */ + private PicrossGrid picrossGrid = null; + + /*** Abstract method ***/ + + /** + * Returns an instance. + * + * @return instance to test + */ + protected abstract PicrossGrid getPicrossGrid(); + + /*** Methods ***/ + + /** Performs the instance initialisation. */ + @Before + public void setUp() { + this.picrossGrid = this.getPicrossGrid(); + } + + /** Tests the method getWidth(). */ + @Test + public void testGetWidth() { + int width = this.picrossGrid.getWidth(); + Assert.assertTrue("width = " + width, (width > 0)); + } + + /** Tests the method getHeight(). */ + @Test + public void testGetHeight() { + int height = this.picrossGrid.getHeight(); + Assert.assertTrue("height = " + height, (height > 0)); + } + + /** Tests the method getData(). */ + @Test + public void testGetData() { + boolean[][] data = this.picrossGrid.getData(); + Assert.assertNotNull("data = null", data); + + int width = this.picrossGrid.getWidth(); + int height = this.picrossGrid.getHeight(); + + Assert.assertEquals("data.length = " + data.length, + width, data.length); + + for (int i = 0; i < width; i++) { + Assert.assertEquals("data[" + i + "].length = " + data[i].length, + height, data[i].length); + } + + boolean atLeastOneCheckedBox = false; + + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + if (data[i][j]) { + atLeastOneCheckedBox = true; + break; + } + } + } + + Assert.assertTrue("Empty grid", atLeastOneCheckedBox); + } +} Copied: branches/engine_split/engine/test/picross/engine/grid/BoxTest.java (from rev 101, branches/engine_split/test/picross/grid/BoxTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/BoxTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/BoxTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,106 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.engine.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class BoxTest { + private Box box = null; + + @Before + public void setUp() { + this.box = new Box(); + } + + @Test + public void testCheck() { + this.box.check(); + Assert.assertTrue("box unchecked", this.box.isChecked()); + } + + @Test + public void testCross() { + this.box.cross(); + Assert.assertTrue("box not crossed", this.box.isCrossed()); + } + + @Test + public void testEmpty() { + this.box.empty(); + Assert.assertTrue("box not empty", this.box.isEmpty()); + } + + @Test + public void testEquals() { + Assert.assertFalse("this.box = null", this.box.equals(null)); + Assert.assertTrue("box != box", this.box.equals(this.box)); + + this.box.check(); + + Box box2 = new Box(); + Assert.assertFalse("box = box2", this.box.equals(box2)); + + box2.check(); + + Assert.assertTrue("box != box2", this.box.equals(box2)); + } + + @Test + public void testIsChecked() { + this.box.check(); + + Assert.assertFalse("box crossed AND checked", this.box.isCrossed()); + Assert.assertFalse("box empty AND checked", this.box.isEmpty()); + } + + @Test + public void testIsCrossed() { + this.box.cross(); + + Assert.assertFalse("box checked AND crossed", this.box.isChecked()); + Assert.assertFalse("box empty AND crossed", this.box.isEmpty()); + } + + @Test + public void testIsEmpty() { + Assert.assertFalse("box checked AND empty", this.box.isChecked()); + Assert.assertFalse("box crossed AND empty", this.box.isCrossed()); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java (from rev 101, branches/engine_split/test/picross/grid/CompletedHintsTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,190 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.engine.grid; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class CompletedHintsTest { + CompletedHints hints = null; + + @Before + public void setUp() { + this.hints = new CompletedHints(10, 10, 10, 10); + } + + @Test(expected = IllegalArgumentException.class) + public void negColWidth() { + new CompletedHints(-1, 1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroColWidth() { + new CompletedHints(0, 1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negColHeight() { + new CompletedHints(1, -1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroColHeight() { + new CompletedHints(1, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negRowWidth() { + new CompletedHints(1, 1, -1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroRowWidth() { + new CompletedHints(1, 1, 0, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negRowHeight() { + new CompletedHints(1, 1, 1, -1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroRowHeight() { + new CompletedHints(1, 1, 1, 0); + } + + @Test + public void completedHints() { + new CompletedHints(1, 1, 1, 1); + } + + @Test + public void testClearColHint() { + this.hints.setCompleteColHint(3, 4); + this.hints.clearColHint(3, 4); + Assert.assertFalse(this.hints.isColHintComplete(3, 4)); + } + + @Test + public void testClearRowHint() { + this.hints.setCompleteRowHint(8, 2); + this.hints.clearRowHint(8, 2); + Assert.assertFalse(this.hints.isRowHintComplete(8, 2)); + } + + @Test(expected = IllegalArgumentException.class) + public void getOutsideColHint() { + this.hints.getCompleteColHints(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void getTooHighColHint() { + this.hints.getCompleteColHints(42); + } + + @Test + public void testGetCompleteColHints() { + List<Integer> complete = this.hints.getCompleteColHints(4); + Assert.assertNotNull("complete = null", complete); + int size = complete.size(); + Assert.assertTrue("size = " + size, (size == 0)); + + this.hints.setCompleteColHint(4, 0); + this.hints.setCompleteColHint(4, 9); + + complete = this.hints.getCompleteColHints(4); + Assert.assertNotNull("complete = null", complete); + size = complete.size(); + Assert.assertTrue("size = " + size, (size == 2)); + + int nb1 = complete.get(0); + Assert.assertTrue("nb1 = " + nb1, (nb1 == 0)); + + int nb2 = complete.get(1); + Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); + } + + @Test(expected = IllegalArgumentException.class) + public void getOutsideRowHint() { + this.hints.getCompleteRowHints(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void getTooHighRowHint() { + this.hints.getCompleteRowHints(42); + } + + @Test + public void testGetCompleteRowHints() { + List<Integer> complete = this.hints.getCompleteRowHints(9); + Assert.assertNotNull("complete = null", complete); + int size = complete.size(); + Assert.assertTrue("size = " + size, (size == 0)); + + this.hints.setCompleteRowHint(9, 3); + this.hints.setCompleteRowHint(9, 6); + + complete = this.hints.getCompleteRowHints(9); + Assert.assertNotNull("complete = null", complete); + size = complete.size(); + Assert.assertTrue("size = " + size, (size == 2)); + + int nb1 = complete.get(0); + Assert.assertTrue("nb1 = " + nb1, (nb1 == 3)); + + int nb2 = complete.get(1); + Assert.assertTrue("nb2 = " + nb2, (nb2 == 6)); + } + + @Test + public void testIsColHintCompleteAndSetCompleteColHint() { + Assert.assertFalse(this.hints.isColHintComplete(0, 0)); + this.hints.setCompleteColHint(0, 0); + Assert.assertTrue(this.hints.isColHintComplete(0, 0)); + } + + @Test + public void testIsRowHintCompleteAndSetCompleteRowHint() { + Assert.assertFalse(this.hints.isRowHintComplete(5, 5)); + this.hints.setCompleteRowHint(5, 5); + Assert.assertTrue(this.hints.isRowHintComplete(5, 5)); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java (from rev 101, branches/engine_split/test/picross/grid/GridModelIntegrationTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,325 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.engine.grid; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelIntegrationTest { + private static Logger log = Logger.getLogger(GridModelIntegrationTest.class); + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + @Test + public void gameSession() { + GridModel gridModel = + new GridModel(new boolean[][] { +{false, false, true, false, false, false, false, true, true, false, true, true}, +{true, false, false, true, false, true, true, true, true, true, false, true}, +{false, false, false, false, false, false, true, false, true, true, false, false}, +{true, false, true, true, false, true, false, false, false, true, true, false}, +{true, true, false, true, true, false, true, false, true, false, false, true}, +{false, false, true, false, false, true, true, false, false, true, true, true}, +{true, true, true, false, true, true, true, false, true, true, false, true}, +{true, false, false, true, true, true, false, true, true, true, true, false}, +{true, false, true, true, false, true, true, false, false, false, true, false}, +{false, false, false, false, false, true, true, true, true, true, false, true}, +{false, true, true, true, false, false, true, true, false, false, false, true}, +{true, true, false, true, true, true, true, true, true, true, true, true}}); + + int[][] hints = gridModel.getRowData(); + + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[5]); + + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 1); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 3); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 3); + gridModel.actOnBox(0, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 2); + gridModel.actOnBox(0, 5, GridAction.CROSS); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(0, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 3); + gridModel.actOnBox(0, 9, GridAction.CROSS); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 4); + + gridModel.actOnBox(1, 0, GridAction.CROSS); + gridModel.actOnBox(1, 1, GridAction.CROSS); + gridModel.actOnBox(1, 2, GridAction.CROSS); + gridModel.actOnBox(1, 3, GridAction.CROSS); + gridModel.actOnBox(1, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 4); + gridModel.actOnBox(1, 5, GridAction.CROSS); + gridModel.actOnBox(1, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 3); + gridModel.actOnBox(1, 7, GridAction.CROSS); + gridModel.actOnBox(1, 8, GridAction.CROSS); + gridModel.actOnBox(1, 9, GridAction.CROSS); + gridModel.actOnBox(1, 10, GridAction.CHECK); + gridModel.actOnBox(1, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 1); + + //gridModel.actOnBox(2, 0, GridAction.EMPTY); + //gridModel.actOnBox(2, 1, GridAction.EMPTY); + gridModel.actOnBox(2, 2, GridAction.CROSS); + gridModel.actOnBox(2, 3, GridAction.CHECK); + gridModel.actOnBox(2, 4, GridAction.CROSS); + gridModel.actOnBox(2, 5, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 5, 2); + gridModel.actOnBox(2, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 3); + gridModel.actOnBox(2, 7, GridAction.CROSS); + gridModel.actOnBox(2, 8, GridAction.CHECK); + gridModel.actOnBox(2, 9, GridAction.CROSS); + gridModel.actOnBox(2, 10, GridAction.CHECK); + gridModel.actOnBox(2, 11, GridAction.CROSS); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 1); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 4); + + //gridModel.actOnBox(3, 0, GridAction.EMPTY); + //gridModel.actOnBox(3, 1, GridAction.EMPTY); + gridModel.actOnBox(3, 2, GridAction.CROSS); + gridModel.actOnBox(3, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 2); + gridModel.actOnBox(3, 4, GridAction.CHECK); + gridModel.actOnBox(3, 5, GridAction.CROSS); + gridModel.actOnBox(3, 6, GridAction.CROSS); + gridModel.actOnBox(3, 7, GridAction.CHECK); + gridModel.actOnBox(3, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 2); + gridModel.actOnBox(3, 9, GridAction.CROSS); + gridModel.actOnBox(3, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 2); + gridModel.actOnBox(3, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 4); + + gridModel.actOnBox(4, 0, GridAction.CROSS); + gridModel.actOnBox(4, 1, GridAction.CROSS); + gridModel.actOnBox(4, 2, GridAction.CROSS); + gridModel.actOnBox(4, 3, GridAction.CROSS); + gridModel.actOnBox(4, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 5, GridAction.CROSS); + gridModel.actOnBox(4, 6, GridAction.CHECK); + gridModel.actOnBox(4, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 8, GridAction.CROSS); + gridModel.actOnBox(4, 9, GridAction.CROSS); + gridModel.actOnBox(4, 10, GridAction.CROSS); + gridModel.actOnBox(4, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 4); + + gridModel.actOnBox(5, 0, GridAction.CROSS); + gridModel.actOnBox(5, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 1); + gridModel.actOnBox(5, 2, GridAction.CROSS); + gridModel.actOnBox(5, 3, GridAction.CROSS); + gridModel.actOnBox(5, 4, GridAction.CROSS); + gridModel.actOnBox(5, 6, GridAction.CHECK); + gridModel.actOnBox(5, 7, GridAction.CHECK); + gridModel.actOnBox(5, 8, GridAction.CHECK); + gridModel.actOnBox(5, 9, GridAction.CHECK); + gridModel.actOnBox(5, 10, GridAction.CROSS); + gridModel.actOnBox(5, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 4); + + gridModel.actOnBox(6, 0, GridAction.CROSS); + gridModel.actOnBox(6, 1, GridAction.CHECK); + gridModel.actOnBox(6, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 1); + gridModel.actOnBox(6, 3, GridAction.CROSS); + gridModel.actOnBox(6, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 2); + gridModel.actOnBox(6, 5, GridAction.CHECK); + gridModel.actOnBox(6, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(6, 7, GridAction.CROSS); + gridModel.actOnBox(6, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 1); + gridModel.actOnBox(6, 9, GridAction.CHECK); + gridModel.actOnBox(6, 10, GridAction.CHECK); + gridModel.actOnBox(6, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 4); + + gridModel.actOnBox(7, 0, GridAction.CHECK); + gridModel.actOnBox(7, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 2); + gridModel.actOnBox(7, 2, GridAction.CROSS); + gridModel.actOnBox(7, 3, GridAction.CROSS); + gridModel.actOnBox(7, 4, GridAction.CROSS); + gridModel.actOnBox(7, 5, GridAction.CROSS); + gridModel.actOnBox(7, 6, GridAction.CROSS); + gridModel.actOnBox(7, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 3); + gridModel.actOnBox(7, 8, GridAction.CROSS); + gridModel.actOnBox(7, 9, GridAction.CHECK); + gridModel.actOnBox(7, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 1); + gridModel.actOnBox(7, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 4); + + gridModel.actOnBox(8, 0, GridAction.CHECK); + gridModel.actOnBox(8, 1, GridAction.CHECK); + gridModel.actOnBox(8, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 0); + gridModel.actOnBox(8, 3, GridAction.CROSS); + gridModel.actOnBox(8, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 1); + gridModel.actOnBox(8, 5, GridAction.CROSS); + gridModel.actOnBox(8, 6, GridAction.CHECK); + gridModel.actOnBox(8, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 2); + gridModel.actOnBox(8, 8, GridAction.CROSS); + gridModel.actOnBox(8, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 3); + gridModel.actOnBox(8, 10, GridAction.CROSS); + gridModel.actOnBox(8, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 4); + + gridModel.actOnBox(9, 0, GridAction.CROSS); + gridModel.actOnBox(9, 1, GridAction.CHECK); + gridModel.actOnBox(9, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 0); + gridModel.actOnBox(9, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 4, GridAction.CROSS); + gridModel.actOnBox(9, 5, GridAction.CHECK); + gridModel.actOnBox(9, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 1); + gridModel.actOnBox(9, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 2); + gridModel.actOnBox(9, 8, GridAction.CROSS); + gridModel.actOnBox(9, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 10, GridAction.CROSS); + gridModel.actOnBox(9, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 4); + + gridModel.actOnBox(10, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 0); + gridModel.actOnBox(10, 1, GridAction.CROSS); + gridModel.actOnBox(10, 2, GridAction.CROSS); + gridModel.actOnBox(10, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 1); +// CHECK +//GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 0); + gridModel.actOnBox(10, 4, GridAction.CROSS); + gridModel.actOnBox(10, 5, GridAction.CHECK); + gridModel.actOnBox(10, 6, GridAction.CROSS); + gridModel.actOnBox(10, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 0); + gridModel.actOnBox(10, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 0); + gridModel.actOnBox(10, 9, GridAction.CROSS); + gridModel.actOnBox(10, 10, GridAction.CROSS); + gridModel.actOnBox(10, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 4); + + gridModel.actOnBox(11, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 0, 0); + gridModel.actOnBox(11, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 0); + gridModel.actOnBox(11, 2, GridAction.CROSS); + gridModel.actOnBox(11, 3, GridAction.CROSS); + gridModel.actOnBox(11, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 0); + gridModel.actOnBox(11, 5, GridAction.CHECK); + gridModel.actOnBox(11, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 0); + gridModel.actOnBox(11, 7, GridAction.CROSS); + gridModel.actOnBox(11, 8, GridAction.CROSS); + gridModel.actOnBox(11, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 0); + gridModel.actOnBox(11, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 0); + gridModel.actOnBox(11, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 0); + + gridModel.actOnBox(5, 5, GridAction.CHECK); + CompletedHints completedHints = gridModel.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(5, 1)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 2)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 3)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 4)); + } + + private static void ensureRowHintComplete(GridModel model, int row, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(row, hintIndex)); + } + + private static void ensureColHintComplete(GridModel model, int col, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(col, hintIndex)); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java (from rev 101, branches/engine_split/test/picross/grid/GridModelTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,269 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.engine.grid; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelTest { + private static Logger log = Logger.getLogger(GridModelTest.class); + + private GridModel model = null; + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + @Before + public void setUp() { + this.model = new GridModel(/*new IGridMediatorStub(),*/ new boolean[3][5]); + } + /* + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullMediator() { + new GridModel(null, new boolean[1][1]); + } + */ + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullData() { + new GridModel(/*new IGridMediatorStub(),*/ null); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithEmptyData() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[0][0]); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutRows() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[1][0]); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutCols() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[0][1]); + } + + @Test + public void checkValidModel() { + GridModel model = new GridModel(new boolean[][] {{true, false, false}, + {false, true, false}}); + Assert.assertFalse(model.checkCompleted()); + + Box[][] boxes = model.getBoxes(); + Assert.assertEquals(2, boxes.length); + Assert.assertEquals(3, boxes[0].length); + Assert.assertEquals(3, boxes[1].length); + + for (Box[] row : boxes) { + for (Box box : row) { + Assert.assertTrue(box.isEmpty()); + } + } + + int[][] colData = model.getColData(); + Assert.assertEquals(2, colData.length); + Assert.assertEquals(1, colData[0].length); + Assert.assertEquals(1, colData[0][0]); + Assert.assertEquals(1, colData[1].length); + Assert.assertEquals(1, colData[1][0]); + + int[][] rowData = model.getRowData(); + Assert.assertEquals(3, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(0, rowData[2][0]); + } + + @Test + public void checkModelWithDifferentNumberOfHints() { + GridModel model = new GridModel(new boolean[][] {{false, false, false, false}, + {true, false, true, true}, + {false, true, false, false}}); + int[][] colData = model.getColData(); + Assert.assertEquals(3, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(0, colData[0][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[0][1]); + Assert.assertEquals(2, colData[1].length); + Assert.assertEquals(2, colData[1][0]); + Assert.assertEquals(1, colData[1][1]); + Assert.assertEquals(2, colData[2].length); + Assert.assertEquals(1, colData[2][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[2][1]); + + int[][] rowData = model.getRowData(); + Assert.assertEquals(4, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(1, rowData[2][0]); + Assert.assertEquals(1, rowData[3].length); + Assert.assertEquals(1, rowData[3][0]); + } + + @Test + public void checkRowHintsInCorrectOrder() { + GridModel model = new GridModel(new boolean[][]{{true},{false},{true},{true}}); + int[][] rowData = model.getRowData(); + Assert.assertEquals(1, rowData.length); + Assert.assertEquals(2, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(2, rowData[0][1]); + } + + @Test + public void checkColHintsInReverseOrder() { + GridModel model = new GridModel(new boolean[][]{{true, false, true, true}}); + int[][] colData = model.getColData(); + Assert.assertEquals(1, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(2, colData[0][0]); + Assert.assertEquals(1, colData[0][1]); + } + + @Test + public void checkEmptyRowsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false, false}, + {true, false}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } + + @Test + public void checkEmptyColsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false}, + {true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + } + + @Test + public void checkEmptyRowHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false}, + {false, false}, + {true, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } + + @Test + public void checkEmptyColHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false, true}, + {false, false, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(1, 1)); + } + + @Test + public void checkRowHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true}, {false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(0, 0)); + model.actOnBox(0, 1, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(0, 0)); + } + + @Test + public void checkColHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true, false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + model.actOnBox(1, 0, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isColHintComplete(0, 0)); + } + + @Test + public void testActOnBox() { + try { + this.model.actOnBox(-1, -1, GridAction.CHECK); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + this.model.actOnBox(0, -1, GridAction.CHECK); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + this.model.actOnBox(0, 0, GridAction.CHECK); + } + + @Test + public void allHintsAreNotOK() { + GridModel gridModel = new GridModel(new boolean[][] {{false, true}, {true, false}, {false, true}, {true, false}, {false, true}, {true, false}, {true, true}, {true, false}, {true, true}, {true, false}, {false, false}, {true, false}}); + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CROSS); + gridModel.actOnBox(0, 4, GridAction.CROSS); + gridModel.actOnBox(0, 5, GridAction.CHECK); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + gridModel.actOnBox(0, 8, GridAction.CHECK); + gridModel.actOnBox(0, 9, GridAction.CHECK); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); + + int[][] hints = gridModel.getRowData(); + + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[0]); + + CompletedHints completedHints = gridModel.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(0, 1)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 2)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 3)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 4)); + } +} + Deleted: branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java =================================================================== --- branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,112 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007-2008 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Abstract test class for the PicrossGrid interface. - * - * @author Y. Norsa - */ -public abstract class AbstractPicrossGridTest { - /*** Field ***/ - - /** The instance to test. */ - private PicrossGrid picrossGrid = null; - - /*** Abstract method ***/ - - /** - * Returns an instance. - * - * @return instance to test - */ - protected abstract PicrossGrid getPicrossGrid(); - - /*** Methods ***/ - - /** Performs the instance initialisation. */ - @Before - public void setUp() { - this.picrossGrid = this.getPicrossGrid(); - } - - /** Tests the method getWidth(). */ - @Test - public void testGetWidth() { - int width = this.picrossGrid.getWidth(); - Assert.assertTrue("width = " + width, (width > 0)); - } - - /** Tests the method getHeight(). */ - @Test - public void testGetHeight() { - int height = this.picrossGrid.getHeight(); - Assert.assertTrue("height = " + height, (height > 0)); - } - - /** Tests the method getData(). */ - @Test - public void testGetData() { - boolean[][] data = this.picrossGrid.getData(); - Assert.assertNotNull("data = null", data); - - int width = this.picrossGrid.getWidth(); - int height = this.picrossGrid.getHeight(); - - Assert.assertEquals("data.length = " + data.length, - width, data.length); - - for (int i = 0; i < width; i++) { - Assert.assertEquals("data[" + i + "].length = " + data[i].length, - height, data[i].length); - } - - boolean atLeastOneCheckedBox = false; - - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - if (data[i][j]) { - atLeastOneCheckedBox = true; - break; - } - } - } - - Assert.assertTrue("Empty grid", atLeastOneCheckedBox); - } -} Deleted: branches/engine_split/test/picross/grid/BoxTest.java =================================================================== --- branches/engine_split/test/picross/grid/BoxTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/BoxTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,123 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007-2008 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class BoxTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private Box box = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - BoxTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.box = new Box(); - } - - @Test - public void testCheck() { - this.box.check(); - Assert.assertTrue("box unchecked", this.box.isChecked()); - } - - @Test - public void testCross() { - this.box.cross(); - Assert.assertTrue("box not crossed", this.box.isCrossed()); - } - - @Test - public void testEmpty() { - this.box.empty(); - Assert.assertTrue("box not empty", this.box.isEmpty()); - } - - @Test - public void testEquals() { - Assert.assertFalse("this.box = null", this.box.equals(null)); - Assert.assertTrue("box != box", this.box.equals(this.box)); - - this.box.check(); - - Box box2 = new Box(); - Assert.assertFalse("box = box2", this.box.equals(box2)); - - box2.check(); - - Assert.assertTrue("box != box2", this.box.equals(box2)); - } - - @Test - public void testIsChecked() { - this.box.check(); - - Assert.assertFalse("box crossed AND checked", this.box.isCrossed()); - Assert.assertFalse("box empty AND checked", this.box.isEmpty()); - } - - @Test - public void testIsCrossed() { - this.box.cross(); - - Assert.assertFalse("box checked AND crossed", this.box.isChecked()); - Assert.assertFalse("box empty AND crossed", this.box.isEmpty()); - } - - @Test - public void testIsEmpty() { - Assert.assertFalse("box checked AND empty", this.box.isChecked()); - Assert.assertFalse("box crossed AND empty", this.box.isCrossed()); - } -} - Deleted: branches/engine_split/test/picross/grid/CompletedHintsTest.java =================================================================== --- branches/engine_split/test/picross/grid/CompletedHintsTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/CompletedHintsTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,207 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007-2008 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class CompletedHintsTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - CompletedHints hints = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - CompletedHintsTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.hints = new CompletedHints(10, 10, 10, 10); - } - - @Test(expected = IllegalArgumentException.class) - public void negColWidth() { - new CompletedHints(-1, 1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroColWidth() { - new CompletedHints(0, 1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negColHeight() { - new CompletedHints(1, -1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroColHeight() { - new CompletedHints(1, 0, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negRowWidth() { - new CompletedHints(1, 1, -1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroRowWidth() { - new CompletedHints(1, 1, 0, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negRowHeight() { - new CompletedHints(1, 1, 1, -1); - ... [truncated message content] |