From a111835984e2d6abbf3dcab317cf97c0f5842ba1 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 1 Mar 2016 17:38:14 +0100 Subject: Reformat code and doc-blocks --- test/ch/epfl/xblast/CellTest.java | 29 ++++++++------ test/ch/epfl/xblast/DirectionTest.java | 2 + test/ch/epfl/xblast/SubCellTest.java | 25 +++++++----- test/ch/epfl/xblast/namecheck/NameCheck01.java | 11 ++++-- test/ch/epfl/xblast/namecheck/NameCheck02.java | 9 +++-- test/ch/epfl/xblast/server/BlockTest.java | 5 ++- test/ch/epfl/xblast/server/BoardTest.java | 53 +++++++++++++------------- 7 files changed, 78 insertions(+), 56 deletions(-) (limited to 'test') diff --git a/test/ch/epfl/xblast/CellTest.java b/test/ch/epfl/xblast/CellTest.java index ba8becc..c5d93e8 100644 --- a/test/ch/epfl/xblast/CellTest.java +++ b/test/ch/epfl/xblast/CellTest.java @@ -1,15 +1,19 @@ package ch.epfl.xblast; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import org.junit.Test; - +/** + * @author EPFL + */ public class CellTest { + @Test public void rowMajorIndexCorrespondsToOrder() { int i = 0; - for (Cell c: Cell.ROW_MAJOR_ORDER) + for (Cell c : Cell.ROW_MAJOR_ORDER) assertEquals(i++, c.rowMajorIndex()); assertEquals(Cell.COUNT, i); } @@ -19,7 +23,7 @@ public class CellTest { assertEquals(Cell.COUNT, Cell.SPIRAL_ORDER.size()); boolean[] cellSeen = new boolean[Cell.COUNT]; - for (Cell c: Cell.SPIRAL_ORDER) { + for (Cell c : Cell.SPIRAL_ORDER) { assertFalse(cellSeen[c.rowMajorIndex()]); cellSeen[c.rowMajorIndex()] = true; } @@ -28,9 +32,9 @@ public class CellTest { @Test public void spiralOrderNeighborsAreSpatialNeighbors() { Cell pred = Cell.SPIRAL_ORDER.get(0); - for (Cell c: Cell.SPIRAL_ORDER.subList(1, Cell.SPIRAL_ORDER.size())) { + for (Cell c : Cell.SPIRAL_ORDER.subList(1, Cell.SPIRAL_ORDER.size())) { int areNeighborsCount = 0; - for (Direction d: Direction.values()) { + for (Direction d : Direction.values()) { if (pred.equals(c.neighbor(d))) areNeighborsCount += 1; } @@ -51,18 +55,19 @@ public class CellTest { @Test public void neighborsOfOriginAreCorrect() { Cell c = new Cell(0, 0); - assertEquals(new Cell( 0, 12), c.neighbor(Direction.N)); - assertEquals(new Cell( 1, 0), c.neighbor(Direction.E)); - assertEquals(new Cell( 0, 1), c.neighbor(Direction.S)); - assertEquals(new Cell(14, 0), c.neighbor(Direction.W)); + assertEquals(new Cell(0, 12), c.neighbor(Direction.N)); + assertEquals(new Cell(1, 0), c.neighbor(Direction.E)); + assertEquals(new Cell(0, 1), c.neighbor(Direction.S)); + assertEquals(new Cell(14, 0), c.neighbor(Direction.W)); } @Test public void oppositeNeighborOfNeighborIsThis() { - for (Cell c: Cell.ROW_MAJOR_ORDER) { - for (Direction d: Direction.values()) { + for (Cell c : Cell.ROW_MAJOR_ORDER) { + for (Direction d : Direction.values()) { assertEquals(c, c.neighbor(d).neighbor(d.opposite())); } } } + } diff --git a/test/ch/epfl/xblast/DirectionTest.java b/test/ch/epfl/xblast/DirectionTest.java index 0ebb3b7..49cf4be 100644 --- a/test/ch/epfl/xblast/DirectionTest.java +++ b/test/ch/epfl/xblast/DirectionTest.java @@ -9,6 +9,7 @@ import static org.junit.Assert.*; * @author Pacien TRAN-GIRARD (261948) */ public class DirectionTest { + @Test public void oppositeOfOppositeIsIdentity() { for (Direction d : Direction.values()) @@ -48,4 +49,5 @@ public class DirectionTest { assertEquals(0, d.yVector() + d.opposite().yVector()); } } + } diff --git a/test/ch/epfl/xblast/SubCellTest.java b/test/ch/epfl/xblast/SubCellTest.java index 1c79791..b3450e1 100644 --- a/test/ch/epfl/xblast/SubCellTest.java +++ b/test/ch/epfl/xblast/SubCellTest.java @@ -1,11 +1,15 @@ package ch.epfl.xblast; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Test; - +/** + * @author EPFL + */ public class SubCellTest { + @Test public void centralSubCellOfKnowCellIsCorrect() { SubCell c = SubCell.centralSubCellOf(new Cell(2, 1)); @@ -15,13 +19,13 @@ public class SubCellTest { @Test public void centralSubCellIsCentral() { - for (Cell c: Cell.ROW_MAJOR_ORDER) + for (Cell c : Cell.ROW_MAJOR_ORDER) assertTrue(SubCell.centralSubCellOf(c).isCentral()); } @Test public void distanceToCentralOfCentralIsZero() { - for (Cell c: Cell.ROW_MAJOR_ORDER) + for (Cell c : Cell.ROW_MAJOR_ORDER) assertEquals(0, SubCell.centralSubCellOf(c).distanceToCentral()); } @@ -43,18 +47,19 @@ public class SubCellTest { @Test public void neighborsOfOriginAreCorrect() { SubCell c = new SubCell(0, 0); - assertEquals(new SubCell( 0, 207), c.neighbor(Direction.N)); - assertEquals(new SubCell( 1, 0), c.neighbor(Direction.E)); - assertEquals(new SubCell( 0, 1), c.neighbor(Direction.S)); - assertEquals(new SubCell(239, 0), c.neighbor(Direction.W)); + assertEquals(new SubCell(0, 207), c.neighbor(Direction.N)); + assertEquals(new SubCell(1, 0), c.neighbor(Direction.E)); + assertEquals(new SubCell(0, 1), c.neighbor(Direction.S)); + assertEquals(new SubCell(239, 0), c.neighbor(Direction.W)); } @Test public void containingCellOfCentralsNeighborIsCorrect() { - for (Cell c: Cell.ROW_MAJOR_ORDER) { + for (Cell c : Cell.ROW_MAJOR_ORDER) { SubCell s = SubCell.centralSubCellOf(c); - for (Direction d: Direction.values()) + for (Direction d : Direction.values()) assertEquals(c, s.neighbor(d).containingCell()); } } + } diff --git a/test/ch/epfl/xblast/namecheck/NameCheck01.java b/test/ch/epfl/xblast/namecheck/NameCheck01.java index 278d85b..7d079c5 100644 --- a/test/ch/epfl/xblast/namecheck/NameCheck01.java +++ b/test/ch/epfl/xblast/namecheck/NameCheck01.java @@ -1,18 +1,20 @@ package ch.epfl.xblast.namecheck; -import java.util.List; - import ch.epfl.xblast.Cell; import ch.epfl.xblast.Direction; import ch.epfl.xblast.SubCell; +import java.util.List; + /** * Classe abstraite utilisant tous les éléments de l'étape 1, pour essayer de * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est * pas un test unitaire, et n'a pas pour but d'être exécuté! + * + * @author EPFL */ - abstract class NameCheck01 { + void checkDirection() { Direction d = Direction.N; d = Direction.E; @@ -36,7 +38,7 @@ abstract class NameCheck01 { } void checkSubCell() { - SubCell c = SubCell.centralSubCellOf(new Cell(0,0)); + SubCell c = SubCell.centralSubCellOf(new Cell(0, 0)); c = new SubCell(0, 0); int t = c.x() + c.y() + c.distanceToCentral(); if (t < 10 && c.isCentral()) @@ -46,4 +48,5 @@ abstract class NameCheck01 { System.out.println(cc); } } + } diff --git a/test/ch/epfl/xblast/namecheck/NameCheck02.java b/test/ch/epfl/xblast/namecheck/NameCheck02.java index 978526e..47c4281 100644 --- a/test/ch/epfl/xblast/namecheck/NameCheck02.java +++ b/test/ch/epfl/xblast/namecheck/NameCheck02.java @@ -1,7 +1,5 @@ package ch.epfl.xblast.namecheck; -import java.util.List; - import ch.epfl.cs108.Sq; import ch.epfl.xblast.Cell; import ch.epfl.xblast.Lists; @@ -9,13 +7,17 @@ import ch.epfl.xblast.server.Block; import ch.epfl.xblast.server.Board; import ch.epfl.xblast.server.Ticks; +import java.util.List; + /** * Classe abstraite utilisant tous les éléments de l'étape 2, pour essayer de * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est * pas un test unitaire, et n'a pas pour but d'être exécuté! + * + * @author EPFL */ - abstract class NameCheck02 { + void checkTicks() { int x = Ticks.PLAYER_DYING_TICKS + Ticks.PLAYER_INVULNERABLE_TICKS @@ -57,4 +59,5 @@ abstract class NameCheck02 { Block l = b.blockAt(c); System.out.println(bs + "/" + l); } + } diff --git a/test/ch/epfl/xblast/server/BlockTest.java b/test/ch/epfl/xblast/server/BlockTest.java index 6cfc853..31fd08a 100644 --- a/test/ch/epfl/xblast/server/BlockTest.java +++ b/test/ch/epfl/xblast/server/BlockTest.java @@ -2,13 +2,15 @@ package ch.epfl.xblast.server; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Timothée FLOURE (257420) * @author pacien TRAN-GIRARD (261948) */ public class BlockTest { + @Test public void free() { assertFalse(Block.INDESTRUCTIBLE_WALL.isFree()); @@ -32,4 +34,5 @@ public class BlockTest { assertTrue(Block.CRUMBLING_WALL.castsShadow()); assertFalse(Block.FREE.castsShadow()); } + } diff --git a/test/ch/epfl/xblast/server/BoardTest.java b/test/ch/epfl/xblast/server/BoardTest.java index b23ac06..5cf2aef 100644 --- a/test/ch/epfl/xblast/server/BoardTest.java +++ b/test/ch/epfl/xblast/server/BoardTest.java @@ -1,49 +1,50 @@ package ch.epfl.xblast.server; -import java.util.List; -import java.util.ArrayList; -import org.junit.Test; import ch.epfl.cs108.Sq; import ch.epfl.xblast.Cell; +import org.junit.Test; -import static org.junit.Assert.*; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertTrue; /** * @author Timothée FLOURE (257420) * @author Pacien TRAN-GIRARD (261948) */ public class BoardTest { - @Test(expected=IllegalArgumentException.class) + + @Test(expected = IllegalArgumentException.class) public void isBoardBuilderEmptyInputThrowingException() { List> blocks = new ArrayList<>(); new Board(blocks); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isBoardBuilderIllegalInputThrowingException() { List> blocks = new ArrayList<>(); - for (int i = 0;i<8;i++) { + for (int i = 0; i < 8; i++) { blocks.add(Sq.constant(Block.FREE)); } new Board(blocks); - } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isOfRowsEmptyInputMatrixThrowingException() { List> rowsList = new ArrayList<>(); Board.ofRows(rowsList); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isOfRowsIllegalInputThrowingException() { List> rowsList = new ArrayList<>(); List sampleRow = new ArrayList<>(); - for (int i = 0;i < 8 ;i++) { + for (int i = 0; i < 8; i++) { sampleRow.add(Block.FREE); } rowsList.add(sampleRow); @@ -53,7 +54,7 @@ public class BoardTest { @Test public void buildBoardFromRowsMatrix() { - List> rowsList = new ArrayList<>() ; + List> rowsList = new ArrayList<>(); for (int i = 0; i < 13; i++) { List sampleRow = new ArrayList<>(); @@ -66,18 +67,18 @@ public class BoardTest { assertTrue(Board.ofRows(rowsList) instanceof Board); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isOfInnerBlocksWalledEmptyInputMatrixThrowingException() { List> rowsList = new ArrayList<>(); Board.ofInnerBlocksWalled(rowsList); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isOfInnerBlocksWalledIllegalInputThrowingException() { List> rowsList = new ArrayList<>(); List sampleRow = new ArrayList<>(); - for (int i = 0;i < 8 ;i++) { + for (int i = 0; i < 8; i++) { sampleRow.add(Block.FREE); } rowsList.add(sampleRow); @@ -87,31 +88,31 @@ public class BoardTest { @Test public void buildBoardFromInnerBlocks() { - List> rowsList = new ArrayList<>() ; + List> rowsList = new ArrayList<>(); for (int i = 0; i < 11; i++) { List sampleRow = new ArrayList<>(); for (int j = 0; j < 13; j++) { - sampleRow.add(Block.FREE); + sampleRow.add(Block.FREE); } - rowsList.add(sampleRow); + rowsList.add(sampleRow); } assertTrue(Board.ofInnerBlocksWalled(rowsList) instanceof Board); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isBuildWithEmptyQuadrantThrowingException() { List> rowsList = new ArrayList<>(); Board.ofQuadrantNWBlocksWalled(rowsList); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void isBuildWithIllegalQuadrantThrowingException() { List> rowsList = new ArrayList<>(); List sampleRow = new ArrayList<>(); - for (int i = 0;i < 8 ;i++) { + for (int i = 0; i < 8; i++) { sampleRow.add(Block.FREE); } rowsList.add(sampleRow); @@ -121,14 +122,14 @@ public class BoardTest { @Test public void buildBoardFromNWQuadrant() { - List> rowsList = new ArrayList<>() ; + List> rowsList = new ArrayList<>(); for (int i = 0; i < 6; i++) { List sampleRow = new ArrayList<>(); for (int j = 0; j < 7; j++) { - sampleRow.add(Block.FREE); + sampleRow.add(Block.FREE); } - rowsList.add(sampleRow); + rowsList.add(sampleRow); } assertTrue(Board.ofQuadrantNWBlocksWalled(rowsList) instanceof Board); @@ -136,8 +137,8 @@ public class BoardTest { @Test public void isBlockAtReturningTheRightBlock() { - Cell sampleCell = new Cell(0,0); - Cell sampleCell2 = new Cell(3,4); + Cell sampleCell = new Cell(0, 0); + Cell sampleCell2 = new Cell(3, 4); List> blocksList = new ArrayList<>(); -- cgit v1.2.3