From cc88afb9fe448b759966e94b07692fb6a154b2bf Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 1 Mar 2016 18:41:39 +0100 Subject: Disambiguate test assertions --- test/ch/epfl/xblast/server/BoardTest.java | 68 ++++++++++++++++++------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'test/ch/epfl') diff --git a/test/ch/epfl/xblast/server/BoardTest.java b/test/ch/epfl/xblast/server/BoardTest.java index 014bd17..a7794d1 100644 --- a/test/ch/epfl/xblast/server/BoardTest.java +++ b/test/ch/epfl/xblast/server/BoardTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** * @author Timothée FLOURE (257420) @@ -48,22 +48,26 @@ public class BoardTest { rowsList.add(sampleRow); - assertTrue(Board.ofRows(rowsList) instanceof Board); + Board.ofRows(rowsList); } @Test public void buildBoardFromRowsMatrix() { - List> rowsList = new ArrayList<>(); + try { + List> rowsList = new ArrayList<>(); - for (int i = 0; i < 13; i++) { - List sampleRow = new ArrayList<>(); - for (int j = 0; j < 15; j++) - sampleRow.add(Block.FREE); + for (int i = 0; i < 13; i++) { + List sampleRow = new ArrayList<>(); + for (int j = 0; j < 15; j++) + sampleRow.add(Block.FREE); - rowsList.add(sampleRow); - } + rowsList.add(sampleRow); + } - assertTrue(Board.ofRows(rowsList) instanceof Board); + assertNotNull(Board.ofRows(rowsList)); + } catch (Exception e) { + fail(e.getMessage()); + } } @Test(expected = IllegalArgumentException.class) @@ -82,22 +86,26 @@ public class BoardTest { rowsList.add(sampleRow); - assertTrue(Board.ofInnerBlocksWalled(rowsList) instanceof Board); + Board.ofInnerBlocksWalled(rowsList); } @Test public void buildBoardFromInnerBlocks() { - List> rowsList = new ArrayList<>(); + try { + 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); + for (int i = 0; i < 11; i++) { + List sampleRow = new ArrayList<>(); + for (int j = 0; j < 13; j++) + sampleRow.add(Block.FREE); - rowsList.add(sampleRow); - } + rowsList.add(sampleRow); + } - assertTrue(Board.ofInnerBlocksWalled(rowsList) instanceof Board); + assertNotNull(Board.ofInnerBlocksWalled(rowsList)); + } catch (Exception e) { + fail(e.getMessage()); + } } @Test(expected = IllegalArgumentException.class) @@ -116,22 +124,26 @@ public class BoardTest { rowsList.add(sampleRow); - assertTrue(Board.ofQuadrantNWBlocksWalled(rowsList) instanceof Board); + Board.ofQuadrantNWBlocksWalled(rowsList); } @Test public void buildBoardFromNWQuadrant() { - List> rowsList = new ArrayList<>(); + try { + 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); + for (int i = 0; i < 6; i++) { + List sampleRow = new ArrayList<>(); + for (int j = 0; j < 7; j++) + sampleRow.add(Block.FREE); - rowsList.add(sampleRow); - } + rowsList.add(sampleRow); + } - assertTrue(Board.ofQuadrantNWBlocksWalled(rowsList) instanceof Board); + assertNotNull(Board.ofQuadrantNWBlocksWalled(rowsList)); + } catch (Exception e) { + fail(e.getMessage()); + } } @Test -- cgit v1.2.3