diff --git a/.besouro/20151009231439788/actions.txt b/.besouro/20151009231439788/actions.txt new file mode 100644 index 0000000..61a1a06 --- /dev/null +++ b/.besouro/20151009231439788/actions.txt @@ -0,0 +1,55 @@ +FileOpenedAction 1444403680299 TestCell.java 200 1 1 0 +RefactoringAction 1444403694906 TestCell.java RENAME test()=>void testCellState() METHOD +RefactoringAction 1444403910054 Cell.java ADD Cell() METHOD +RefactoringAction 1444403915134 Cell.java RENAME Cell()=>Cell(String) METHOD +RefactoringAction 1444403943297 Cell.java ADD String state FIELD +EditAction 1444403951537 Cell.java 138 1 1 0 +EditAction 1444403951925 TestCell.java 234 1 2 1 +CompilationAction 1444403952476 TestCell.java +RefactoringAction 1444403974675 TestCell.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +UnitTestCaseAction 1444403991175 TestSudokuVerifier.java OK +UnitTestSessionAction 1444403991181 TestSudokuVerifier OK +UnitTestCaseAction 1444404011298 TestSudokuVerifier.java OK +UnitTestSessionAction 1444404011301 TestSudokuVerifier OK +RefactoringAction 1444404048265 Cell.java ADD String getState() METHOD +RefactoringAction 1444404048267 Cell.java ADD void setState(String) METHOD +EditAction 1444404061817 Cell.java 250 3 3 0 +CompilationAction 1444404062049 TestCell.java +CompilationAction 1444404062286 TestCell.java +CompilationAction 1444404081652 TestCell.java +UnitTestCaseAction 1444404084996 TestCell.java OK +UnitTestSessionAction 1444404085001 TestCell OK +EditAction 1444404266513 TestCell.java 287 1 2 1 +UnitTestCaseAction 1444404268456 TestCell.java FAIL +UnitTestSessionAction 1444404268457 TestCell FAIL +EditAction 1444404278633 TestCell.java 287 1 2 1 +UnitTestCaseAction 1444404280915 TestCell.java OK +UnitTestSessionAction 1444404280915 TestCell OK +FileOpenedAction 1444404316484 Grid.java 68 0 0 0 +FileOpenedAction 1444404318810 TestGrid.java 199 1 1 0 +RefactoringAction 1444404357329 TestGrid.java RENAME test()=>void testGrid() METHOD +RefactoringAction 1444404388532 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Grid IMPORT +RefactoringAction 1444404401862 Grid.java ADD Grid(int) METHOD +RefactoringAction 1444404470381 Grid.java ADD Cell FIELD +FileOpenedAction 1444404528049 Cell.java 250 3 3 0 +RefactoringAction 1444404640183 Grid.java ADD Cell METHOD +RefactoringAction 1444404640184 Grid.java ADD void setGrid(Cell METHOD +EditAction 1444404646165 Grid.java 260 3 3 0 +EditAction 1444404646392 TestGrid.java 250 1 1 0 +FileOpenedAction 1444404701570 Cell.java 250 3 3 0 +EditAction 1444404749636 TestGrid.java 330 1 3 1 +UnitTestCaseAction 1444404752929 TestGrid.java FAIL +UnitTestSessionAction 1444404752932 TestGrid FAIL +UnitTestCaseAction 1444404892941 TestGrid.java FAIL +UnitTestSessionAction 1444404892942 TestGrid FAIL +EditAction 1444404911494 TestGrid.java 330 1 3 1 +UnitTestCaseAction 1444404913542 TestGrid.java FAIL +UnitTestSessionAction 1444404913543 TestGrid FAIL +RefactoringAction 1444404933643 Grid.java ADD static void main(String METHOD +RefactoringAction 1444404944698 Grid.java ADD import org.junit.Assert.assertEquals IMPORT +EditAction 1444404980291 Grid.java 462 4 6 0 +FileOpenedAction 1444404995026 Cell.java 250 3 3 0 +EditAction 1444405035009 Grid.java 418 4 5 0 +EditAction 1444405157894 Grid.java 420 4 4 0 +EditAction 1444405191671 Grid.java 420 4 5 0 +EditAction 1444405205845 Grid.java 420 4 5 0 diff --git a/.besouro/20151009231439788/besouroEpisodes.txt b/.besouro/20151009231439788/besouroEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009231439788/disagreements.txt b/.besouro/20151009231439788/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009231439788/randomHeuristicEpisodes.txt b/.besouro/20151009231439788/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009231439788/userComments.txt b/.besouro/20151009231439788/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009231439788/zorroEpisodes.txt b/.besouro/20151009231439788/zorroEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014002642788/actions.txt b/.besouro/20151014002642788/actions.txt new file mode 100644 index 0000000..2c70f55 --- /dev/null +++ b/.besouro/20151014002642788/actions.txt @@ -0,0 +1,91 @@ +FileOpenedAction 1444753603434 TestGrid.java 330 1 3 1 +UnitTestCaseAction 1444753828577 TestGrid.java FAIL +UnitTestSessionAction 1444753828582 TestGrid FAIL +EditAction 1444753837294 TestGrid.java 330 1 3 1 +UnitTestCaseAction 1444753839850 TestGrid.java OK +UnitTestSessionAction 1444753839855 TestGrid OK +RefactoringAction 1444754339071 TestGrid.java RENAME testGrid()=>void testCreatGrid() METHOD +EditAction 1444754340771 TestGrid.java 335 1 3 1 +RefactoringAction 1444754344650 TestGrid.java RENAME testCreatGrid()=>void testCreateGrid() METHOD +EditAction 1444754345428 TestGrid.java 336 1 3 1 +RefactoringAction 1444754363157 TestGrid.java ADD void testCreateGrid()/2 METHOD +RefactoringAction 1444754369695 TestGrid.java RENAME testCreateGrid()/2=>void testGrid() METHOD +RefactoringAction 1444754372208 TestGrid.java RENAME testGrid()=>void testShowGrid() METHOD +RefactoringAction 1444754391254 TestGrid.java RENAME testShowGrid()=>void testGrid() METHOD +RefactoringAction 1444754393816 TestGrid.java RENAME testGrid()=>void testDisGrid() METHOD +RefactoringAction 1444754395854 TestGrid.java RENAME testDisGrid()=>void testDisplGrid() METHOD +RefactoringAction 1444754397401 TestGrid.java RENAME testDisplGrid()=>void testDisplyaGrid() METHOD +RefactoringAction 1444754399933 TestGrid.java RENAME testDisplyaGrid()=>void testDisplGrid() METHOD +RefactoringAction 1444754401464 TestGrid.java RENAME testDisplGrid()=>void testDisplayGrid() METHOD +RefactoringAction 1444754553307 Grid.java ADD void display() METHOD +RefactoringAction 1444754633325 Grid.java ADD int size FIELD +EditAction 1444754818240 Grid.java 762 5 11 0 +EditAction 1444754821983 TestGrid.java 613 2 9 1 +UnitTestCaseAction 1444754826309 TestGrid.java OK +UnitTestSessionAction 1444754826311 TestGrid OK +RefactoringAction 1444754865125 Grid.java REMOVE main(String METHOD +EditAction 1444754867366 Grid.java 604 4 8 0 +EditAction 1444754881132 Grid.java 602 4 8 0 +UnitTestCaseAction 1444754885111 TestGrid.java OK +UnitTestSessionAction 1444754885112 TestGrid OK +RefactoringAction 1444765123130 TestGrid.java ADD void testDisplayGrid()/2 METHOD +RefactoringAction 1444765130161 TestGrid.java RENAME testDisplayGrid()/2=>void testGrid() METHOD +RefactoringAction 1444765132189 TestGrid.java RENAME testGrid()=>void test() METHOD +RefactoringAction 1444765136705 TestGrid.java RENAME test()=>void testCount() METHOD +RefactoringAction 1444765143726 TestGrid.java RENAME testCreateGrid()=>void testCreate() METHOD +RefactoringAction 1444765147738 TestGrid.java RENAME testDisplayGrid()=>void testDisplay() METHOD +EditAction 1444765154966 TestGrid.java 876 3 15 1 +RefactoringAction 1444765252676 Grid.java ADD Object count(int, int) METHOD +EditAction 1444765259600 TestGrid.java 842 3 15 2 +CompilationAction 1444765259840 TestGrid.java +EditAction 1444765276517 Grid.java 695 5 9 0 +UnitTestCaseAction 1444765278351 TestGrid.java FAIL +UnitTestSessionAction 1444765278351 TestGrid FAIL +UnitTestCaseAction 1444766024571 TestGrid.java OK +UnitTestSessionAction 1444766024571 TestGrid OK +EditAction 1444766437664 Grid.java 3302 5 10 0 +CompilationAction 1444766437900 Grid.java +EditAction 1444766535761 Grid.java 3869 5 10 0 +CompilationAction 1444766536010 Grid.java +EditAction 1444766564539 Grid.java 3884 5 10 0 +RefactoringAction 1444766596318 TestGrid.java ADD void testCount()/2 METHOD +RefactoringAction 1444766605357 TestGrid.java RENAME testCount()/2=>void testCount2() METHOD +EditAction 1444766757282 TestGrid.java 1324 4 28 5 +UnitTestCaseAction 1444766759757 TestGrid.java OK +UnitTestSessionAction 1444766759758 TestGrid OK +RefactoringAction 1444766807582 TestGrid.java ADD void testCount2()/2 METHOD +RefactoringAction 1444766816107 TestGrid.java RENAME testCount2()/2=>void test() METHOD +RefactoringAction 1444766818622 TestGrid.java RENAME test()=>void testTick() METHOD +EditAction 1444766896740 TestGrid.java 1743 5 41 5 +CompilationAction 1444766896967 TestGrid.java +UnitTestCaseAction 1444766902284 TestGrid.java FAIL +UnitTestSessionAction 1444766902285 TestGrid FAIL +RefactoringAction 1444766912395 Grid.java ADD void tick() METHOD +EditAction 1444767603448 Grid.java 4561 6 14 0 +UnitTestCaseAction 1444767610496 TestGrid.java OK +UnitTestSessionAction 1444767610497 TestGrid OK +EditAction 1444767684579 TestGrid.java 1743 5 41 5 +UnitTestCaseAction 1444767686376 TestGrid.java OK +UnitTestSessionAction 1444767686377 TestGrid OK +EditAction 1444767788335 TestGrid.java 1743 5 41 5 +UnitTestCaseAction 1444767930144 TestGrid.java OK +UnitTestSessionAction 1444767930145 TestGrid OK +EditAction 1444768013735 TestGrid.java 1777 5 42 6 +UnitTestCaseAction 1444768015724 TestGrid.java OK +UnitTestSessionAction 1444768015724 TestGrid OK +UnitTestCaseAction 1444768104107 TestGrid.java OK +UnitTestSessionAction 1444768104108 TestGrid OK +EditAction 1444768215238 TestGrid.java 1845 5 44 8 +UnitTestCaseAction 1444768217415 TestGrid.java OK +UnitTestSessionAction 1444768217415 TestGrid OK +EditAction 1444768351212 TestGrid.java 1872 5 46 8 +UnitTestCaseAction 1444768353167 TestGrid.java OK +UnitTestSessionAction 1444768353167 TestGrid OK +RefactoringAction 1444768422089 GameOfLife.java ADD static void main(String METHOD +EditAction 1444768472991 GameOfLife.java 526 1 15 0 +EditAction 1444768565553 GameOfLife.java 351 1 10 0 +EditAction 1444768592851 GameOfLife.java 351 1 10 0 +EditAction 1444768609382 GameOfLife.java 351 1 10 0 +EditAction 1444768746747 GameOfLife.java 671 1 15 0 +EditAction 1444769464013 GameOfLife.java 526 1 15 0 +EditAction 1444769467298 Grid.java 4561 6 14 0 diff --git a/.besouro/20151014002642788/besouroEpisodes.txt b/.besouro/20151014002642788/besouroEpisodes.txt new file mode 100644 index 0000000..dc42537 --- /dev/null +++ b/.besouro/20151014002642788/besouroEpisodes.txt @@ -0,0 +1,18 @@ +1444753839855 regression 2 236 true +1444754826311 test-addition 1 487 true +1444754885112 refactoring 2A 19 true +1444766024571 test-first 2 901 true +1444766024572 test-first 2 901 true +1444766759758 test-last 1 322 false +1444766759759 test-last 1 322 false +1444766759760 test-last 1 322 false +1444766759761 test-last 1 322 false +1444766759762 test-last 1 322 false +1444766759763 test-last 1 322 false +1444767610497 test-first 1 802 true +1444767686377 regression 1 1 true +1444767930145 regression 1 141 true +1444768015724 test-addition 1 1 true +1444768104108 regression 1 0 true +1444768217415 test-addition 1 2 true +1444768353167 refactoring 1A 1 true diff --git a/.besouro/20151014002642788/disagreements.txt b/.besouro/20151014002642788/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014002642788/randomHeuristicEpisodes.txt b/.besouro/20151014002642788/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..60477a5 --- /dev/null +++ b/.besouro/20151014002642788/randomHeuristicEpisodes.txt @@ -0,0 +1,12 @@ +1444753839855 regression 2 236 false +1444754826311 test-addition 1 487 true +1444754885112 refactoring 2A 19 false +1444766024571 test-first 2 901 true +1444766759758 test-last 1 322 false +1444767610497 test-first 1 802 true +1444767686377 regression 1 1 false +1444767930145 regression 1 141 false +1444768015724 test-addition 1 1 true +1444768104108 regression 1 0 false +1444768217415 test-addition 1 2 false +1444768353167 refactoring 1A 1 true diff --git a/.besouro/20151014002642788/userComments.txt b/.besouro/20151014002642788/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014002642788/zorroEpisodes.txt b/.besouro/20151014002642788/zorroEpisodes.txt new file mode 100644 index 0000000..420d76f --- /dev/null +++ b/.besouro/20151014002642788/zorroEpisodes.txt @@ -0,0 +1,12 @@ +1444753839855 regression 2 236 true +1444754826311 test-addition 1 986 true +1444754885112 refactoring 2A 58 true +1444766024571 test-first 2 11139 true +1444766759758 test-last 1 735 false +1444767610497 test-first 1 850 true +1444767686377 regression 1 75 true +1444767930145 regression 1 243 true +1444768015724 test-addition 1 85 true +1444768104108 regression 1 88 true +1444768217415 test-addition 1 113 true +1444768353167 refactoring 1A 135 true diff --git a/.besouro/20151014045132265/actions.txt b/.besouro/20151014045132265/actions.txt new file mode 100644 index 0000000..482d840 --- /dev/null +++ b/.besouro/20151014045132265/actions.txt @@ -0,0 +1 @@ +FileOpenedAction 1444769492453 GameOfLife.java 526 1 15 0 diff --git a/.besouro/20151014045132265/besouroEpisodes.txt b/.besouro/20151014045132265/besouroEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014045132265/disagreements.txt b/.besouro/20151014045132265/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014045132265/randomHeuristicEpisodes.txt b/.besouro/20151014045132265/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014045132265/userComments.txt b/.besouro/20151014045132265/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151014045132265/zorroEpisodes.txt b/.besouro/20151014045132265/zorroEpisodes.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java index b66e9c8..4f5738d 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java @@ -1,5 +1,18 @@ package org.unioulu.tol.sqatlab.gameoflife; public class Cell { + private String state; + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Cell(String s) + { + this.state = s; + } } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/GameOfLife.java b/src/org/unioulu/tol/sqatlab/gameoflife/GameOfLife.java index dbd5f88..f67c401 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/GameOfLife.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/GameOfLife.java @@ -1,5 +1,21 @@ package org.unioulu.tol.sqatlab.gameoflife; public class GameOfLife { - + public static void main(String[] args) { + Grid g = new Grid(3); + g.getGrid()[0][0].setState("*"); + g.getGrid()[0][1].setState("*"); + g.getGrid()[0][2].setState("*"); + g.getGrid()[1][0].setState("*"); + g.getGrid()[1][1].setState("-"); + g.getGrid()[1][2].setState("*"); + g.getGrid()[2][0].setState("*"); + g.getGrid()[2][1].setState("*"); + g.getGrid()[2][2].setState("*"); + g.display(); + g.tick(); + g.display(); + g.tick(); + g.display(); + } } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java index 19dbf0b..51949d2 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java @@ -1,5 +1,279 @@ package org.unioulu.tol.sqatlab.gameoflife; public class Grid { + private Cell[][] grid; + private int size; + + public Cell[][] getGrid() { + return grid; + } + public void setGrid(Cell[][] grid) { + this.grid = grid; + } + + public Grid(int n) { + this.size = n; + this.grid = new Cell[n][n]; + int i = 0, j = 0; + for (; i < n; i++) + { + for (j = 0; j < n; j++) + { + grid[i][j] = new Cell(""); + } + } + } + + public void display() { + int i = 0, j = 0; + for (; i < size; i++) + { + for (j = 0; j < size; j++) + { + System.out.print(grid[i][j].getState()); + } + System.out.println(); + } + } + + public int count(int i, int j) { + int cnt = 0; + if (i == 0 && j == 0) + { + if (grid[0][1].getState().equals("*")) + { + cnt++; + } + if (grid[1][0].getState().equals("*")) + { + cnt++; + } + if (grid[1][1].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (i == 0 && j == size - 1) + { + if (grid[0][size - 2].getState().equals("*")) + { + cnt++; + } + if (grid[1][size - 1].getState().equals("*")) + { + cnt++; + } + if (grid[1][size - 2].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (i == size - 1 && j == 0) + { + if (grid[size - 2][0].getState().equals("*")) + { + cnt++; + } + if (grid[size - 1][1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 2][1].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (i == size - 1 && j == size - 1) + { + if (grid[size - 2][size - 1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 1][size - 2].getState().equals("*")) + { + cnt++; + } + if (grid[size - 2][size - 2].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (i == 0) + { + if (grid[0][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[0][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[1][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[1][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[1][j].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (i == size - 1) + { + if (grid[size - 1][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 1][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 2][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 2][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[size - 2][j].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (j == 0) + { + if (grid[i - 1][0].getState().equals("*")) + { + cnt++; + } + if (grid[i - 1][1].getState().equals("*")) + { + cnt++; + } + if (grid[i][1].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][0].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][1].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else if (j == size - 1) + { + if (grid[i - 1][size - 2].getState().equals("*")) + { + cnt++; + } + if (grid[i - 1][size - 1].getState().equals("*")) + { + cnt++; + } + if (grid[i][size - 2].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][size - 2].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][size - 1].getState().equals("*")) + { + cnt++; + } + return cnt; + } + else + { + if (grid[i - 1][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[i - 1][j].getState().equals("*")) + { + cnt++; + } + if (grid[i - 1][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[i][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[i][j + 1].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][j - 1].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][j].getState().equals("*")) + { + cnt++; + } + if (grid[i + 1][j + 1].getState().equals("*")) + { + cnt++; + } + return cnt; + } + } + + public void tick() { + Grid help = new Grid(size); + int i = 0, j = 0; + for (; i < size; i++) + { + for (j = 0; j < size; j++) + { + if (grid[i][j].getState().equals("*")) + { + if (count(i, j) == 2 || count(i, j) == 3) + { + help.getGrid()[i][j].setState("*"); + } + else + { + help.getGrid()[i][j].setState("-"); + } + } + else + { + if (count(i, j) == 3) + { + help.getGrid()[i][j].setState("*"); + } + else + { + help.getGrid()[i][j].setState("-"); + } + } + } + } + for (i = 0; i < size; i++) + { + for (j = 0; j < size; j++) + { + grid[i][j].setState(help.getGrid()[i][j].getState()); + } + } + } } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java index d8de09e..469739e 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java @@ -3,12 +3,14 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.unioulu.tol.sqatlab.gameoflife.Cell; public class TestCell { @Test - public void test() { - fail("Not yet implemented"); + public void testCellState() { + Cell c = new Cell("*"); + assertEquals("*", c.getState()); } } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java index 9614d55..298d46e 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java @@ -2,12 +2,75 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.unioulu.tol.sqatlab.gameoflife.Grid; public class TestGrid { @Test - public void test() { - fail("Not yet implemented"); + public void testCreate() { + Grid g = new Grid(5); + g.getGrid()[1][1].setState("-"); + assertEquals("-", g.getGrid()[1][1].getState()); } - + + @Test + public void testDisplay() { + Grid g = new Grid(2); + g.getGrid()[0][0].setState("-"); + g.getGrid()[0][1].setState("-"); + g.getGrid()[1][0].setState("-"); + g.getGrid()[1][1].setState("-"); + g.display(); + //assertEquals("-", g.getGrid()[1][1].getState()); + } + + @Test + public void testCount() { + Grid g = new Grid(2); + g.getGrid()[0][0].setState("-"); + g.getGrid()[0][1].setState("-"); + g.getGrid()[1][0].setState("-"); + g.getGrid()[1][1].setState("-"); + assertEquals(0, g.count(0, 0)); + } + + @Test + public void testCount2() { + Grid g = new Grid(3); + g.getGrid()[0][0].setState("*"); + g.getGrid()[0][1].setState("*"); + g.getGrid()[0][2].setState("*"); + g.getGrid()[1][0].setState("*"); + g.getGrid()[1][1].setState("-"); + g.getGrid()[1][2].setState("*"); + g.getGrid()[2][0].setState("*"); + g.getGrid()[2][1].setState("*"); + g.getGrid()[2][2].setState("*"); + assertEquals(8, g.count(1, 1)); + assertEquals(2, g.count(0, 0)); + assertEquals(4, g.count(0, 1)); + assertEquals(4, g.count(1, 0)); + assertEquals(4, g.count(2, 1)); + assertEquals(4, g.count(1, 2)); + } + + @Test + public void testTick() { + Grid g = new Grid(3); + g.getGrid()[0][0].setState("*"); + g.getGrid()[0][1].setState("*"); + g.getGrid()[0][2].setState("*"); + g.getGrid()[1][0].setState("*"); + g.getGrid()[1][1].setState("-"); + g.getGrid()[1][2].setState("*"); + g.getGrid()[2][0].setState("*"); + g.getGrid()[2][1].setState("*"); + g.getGrid()[2][2].setState("*"); + g.display(); + g.tick(); + g.display(); + g.tick(); + g.display(); + } + }