diff --git a/.besouro/2015100912171338/actions.txt b/.besouro/2015100912171338/actions.txt new file mode 100644 index 0000000..7e563f0 --- /dev/null +++ b/.besouro/2015100912171338/actions.txt @@ -0,0 +1,141 @@ +FileOpenedAction 1444382233633 TestCell.java 214 1 2 0 +RefactoringAction 1444382415295 TestCell.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444382419786 Cell.java ADD Cell(String) METHOD +RefactoringAction 1444382430462 Cell.java ADD void nextIteration() METHOD +RefactoringAction 1444382436071 Cell.java ADD Object getState() METHOD +UnitTestCaseAction 1444382465610 TestSudokuVerifier.java OK +UnitTestSessionAction 1444382465617 TestSudokuVerifier OK +EditAction 1444382508374 Cell.java 286 3 1 0 +EditAction 1444382511620 TestCell.java 372 1 3 1 +UnitTestCaseAction 1444382515566 TestCell.java OK +UnitTestSessionAction 1444382515567 TestSudokuVerifier OK +RefactoringAction 1444382548606 TestCell.java ADD void testLiveCellWithNoNeighborsShouldDie()/2 METHOD +RefactoringAction 1444382556119 TestCell.java RENAME testLiveCellWithNoNeighborsShouldDie()/2=>void testLiveCellWithTNoNeighborsShouldDie() METHOD +RefactoringAction 1444382557134 TestCell.java RENAME testLiveCellWithTNoNeighborsShouldDie()=>void testLiveCellWithTwoNoNeighborsShouldDie() METHOD +RefactoringAction 1444382561150 TestCell.java RENAME testLiveCellWithTwoNoNeighborsShouldDie()=>void testLiveCellWithTwoNeighborsShouldDie() METHOD +RefactoringAction 1444382567164 TestCell.java RENAME testLiveCellWithTwoNeighborsShouldDie()=>void testLiveCellWithTwoNeighborsShould() METHOD +RefactoringAction 1444382568679 TestCell.java RENAME testLiveCellWithTwoNeighborsShould()=>void testLiveCellWithTwoNeighborsShouldLive() METHOD +EditAction 1444382586081 TestCell.java 554 2 6 2 +UnitTestCaseAction 1444382590154 TestCell.java FAIL +UnitTestSessionAction 1444382590155 TestSudokuVerifier FAIL +RefactoringAction 1444382637204 Cell.java ADD String state FIELD +UnitTestCaseAction 1444382698193 TestCell.java FAIL +UnitTestSessionAction 1444382698195 TestSudokuVerifier FAIL +RefactoringAction 1444382833794 Cell.java RENAME nextIteration()=>void nextIteration(int) METHOD +CompilationAction 1444383018701 TestCell.java +EditAction 1444383018830 TestCell.java 556 2 6 2 +UnitTestCaseAction 1444383022775 TestCell.java OK +UnitTestSessionAction 1444383022776 TestSudokuVerifier OK +RefactoringAction 1444383044962 TestCell.java ADD void testLiveCellWithTwoNeighborsShouldLive()/2 METHOD +RefactoringAction 1444383051475 TestCell.java RENAME testLiveCellWithTwoNeighborsShouldLive()/2=>void testDeadCellWithTwoNeighborsShouldLive() METHOD +RefactoringAction 1444383055986 TestCell.java RENAME testDeadCellWithTwoNeighborsShouldLive()=>void testDeadCellWithNeighborsShouldLive() METHOD +RefactoringAction 1444383057495 TestCell.java RENAME testDeadCellWithNeighborsShouldLive()=>void testDeadCellWithNoNeighborsShouldLive() METHOD +RefactoringAction 1444383061508 TestCell.java RENAME testDeadCellWithNoNeighborsShouldLive()=>void testDeadCellWithNoLiveNeighborsShouldLive() METHOD +RefactoringAction 1444383115925 TestGrid.java RENAME test()=>void single() METHOD +RefactoringAction 1444383118433 TestGrid.java RENAME single()=>void singleCell() METHOD +RefactoringAction 1444383215745 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Grid IMPORT +RefactoringAction 1444383218728 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444383423489 Cell.java ADD Cell(int, int) METHOD +RefactoringAction 1444383433108 Cell.java RENAME Cell(int, int)=>Cell(int) METHOD +RefactoringAction 1444383434118 Cell.java RENAME Cell(int)=>Cell(int, int) METHOD +RefactoringAction 1444383447647 Cell.java ADD int x FIELD +RefactoringAction 1444383450670 Cell.java ADD int y FIELD +RefactoringAction 1444383487607 Grid.java ADD int getNeighbors(Cell) METHOD +EditAction 1444383495726 TestGrid.java 430 1 4 1 +EditAction 1444383500314 Grid.java 169 1 1 0 +EditAction 1444383503273 Cell.java 477 4 5 0 +EditAction 1444383506438 TestCell.java 739 3 9 3 +UnitTestCaseAction 1444383512002 TestGrid.java OK +UnitTestSessionAction 1444383512008 TestGrid OK +RefactoringAction 1444383551595 TestGrid.java ADD void singleCell()/2 METHOD +RefactoringAction 1444383562104 TestGrid.java RENAME singleCell()/2=>void test() METHOD +RefactoringAction 1444383565120 TestGrid.java RENAME test()=>void testSingle() METHOD +RefactoringAction 1444383567129 TestGrid.java RENAME testSingle()=>void testSingleCell() METHOD +RefactoringAction 1444383568643 TestGrid.java RENAME testSingleCell()=>void testSingleCellOn() METHOD +RefactoringAction 1444383571153 TestGrid.java RENAME testSingleCellOn()=>void testSingleCellOnGrid() METHOD +RefactoringAction 1444383572664 TestGrid.java RENAME testSingleCellOnGrid()=>void testSingleCellOnGridHas() METHOD +RefactoringAction 1444383573673 TestGrid.java RENAME testSingleCellOnGridHas()=>void testSingleCellOnGridHasNo() METHOD +RefactoringAction 1444383576181 TestGrid.java RENAME testSingleCellOnGridHasNo()=>void testSingleCellOnGridHasNoNeig() METHOD +RefactoringAction 1444383577693 TestGrid.java RENAME testSingleCellOnGridHasNoNeig()=>void testSingleCellOnGridHasNoNeigh() METHOD +RefactoringAction 1444383579702 TestGrid.java RENAME testSingleCellOnGridHasNoNeigh()=>void testSingleCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383599234 TestGrid.java REMOVE singleCell() METHOD +RefactoringAction 1444383622259 Grid.java ADD void addCell(Cell) METHOD +EditAction 1444383636118 TestGrid.java 495 1 5 1 +CompilationAction 1444383639351 TestGrid.java +EditAction 1444383639487 Grid.java 252 2 1 0 +UnitTestCaseAction 1444383645588 TestGrid.java OK +UnitTestSessionAction 1444383645589 TestGrid OK +RefactoringAction 1444383652871 TestGrid.java ADD void testSingleCellOnGridHasNoNeighbors()/2 METHOD +RefactoringAction 1444383721604 TestGrid.java RENAME testSingleCellOnGridHasNoNeighbors()/2=>void testCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383723615 TestGrid.java RENAME testCellOnGridHasNoNeighbors()=>void testTwoCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383727627 TestGrid.java RENAME testTwoCellOnGridHasNoNeighbors()=>void testTwoNeightCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383729642 TestGrid.java RENAME testTwoNeightCellOnGridHasNoNeighbors()=>void testTwoNeightborCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383731654 TestGrid.java RENAME testTwoNeightborCellOnGridHasNoNeighbors()=>void testTwoNeightborCellCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383735664 TestGrid.java RENAME testTwoNeightborCellCellOnGridHasNoNeighbors()=>void testTwoNeightborCells() METHOD +RefactoringAction 1444383740175 TestGrid.java RENAME testTwoNeightborCells()=>void testTwoNeightborCellsShouldHave() METHOD +RefactoringAction 1444383742186 TestGrid.java RENAME testTwoNeightborCellsShouldHave()=>void testTwoNeightborCellsShouldHaveOne() METHOD +RefactoringAction 1444383747202 TestGrid.java RENAME testTwoNeightborCellsShouldHaveOne()=>void testTwoNeightborCellsShouldHaveOneNe() METHOD +RefactoringAction 1444383749716 TestGrid.java RENAME testTwoNeightborCellsShouldHaveOneNe()=>void testTwoNeightborCellsShouldHaveOneNeight() METHOD +RefactoringAction 1444383751727 TestGrid.java RENAME testTwoNeightborCellsShouldHaveOneNeight()=>void testTwoNeightborCellsShouldHaveOneNeighbi() METHOD +RefactoringAction 1444383755246 TestGrid.java RENAME testTwoNeightborCellsShouldHaveOneNeighbi()=>void testTwoNeightborCellsShouldHaveOneNeighbor() METHOD +EditAction 1444383761912 TestGrid.java 811 2 12 2 +UnitTestCaseAction 1444383766613 TestGrid.java FAIL +UnitTestSessionAction 1444383766614 TestGrid.testTwoNeightborCellsShouldHaveOneNeighbor FAIL +RefactoringAction 1444384611457 Grid.java ADD Set cell FIELD +RefactoringAction 1444384612467 Grid.java RENAME cell=>Set cells FIELD +RefactoringAction 1444384635501 Grid.java ADD import java.util.HashSet IMPORT +RefactoringAction 1444384647069 Grid.java ADD import java.util.Set IMPORT +RefactoringAction 1444384705120 Cell.java ADD int hashCode() METHOD +RefactoringAction 1444384705122 Cell.java ADD boolean equals(Object) METHOD +EditAction 1444384729803 Cell.java 1158 6 19 0 +UnitTestCaseAction 1444384734043 TestGrid.java FAIL +UnitTestSessionAction 1444384734044 TestGrid.testTwoNeightborCellsShouldHaveOneNeighbor FAIL +UnitTestCaseAction 1444384741808 TestGrid.java FAIL +UnitTestSessionAction 1444384741809 TestGrid FAIL +RefactoringAction 1444384962243 Cell.java REMOVE hashCode() METHOD +RefactoringAction 1444384962244 Cell.java REMOVE equals(Object) METHOD +RefactoringAction 1444384968269 Cell.java ADD int hashCode() METHOD +RefactoringAction 1444384968270 Cell.java ADD boolean equals(Object) METHOD +RefactoringAction 1444384987843 Cell.java ADD int get() METHOD +RefactoringAction 1444384993854 Cell.java RENAME get()=>int getX() METHOD +RefactoringAction 1444385009373 Cell.java REMOVE getX() METHOD +RefactoringAction 1444385029386 Cell.java ADD int getX() METHOD +RefactoringAction 1444385029387 Cell.java ADD void setX(int) METHOD +RefactoringAction 1444385029388 Cell.java ADD int getY() METHOD +RefactoringAction 1444385029389 Cell.java ADD void setY(int) METHOD +EditAction 1444385072192 Grid.java 345 2 3 0 +EditAction 1444385076545 Cell.java 1341 10 23 0 +RefactoringAction 1444385519937 Grid.java RENAME getNeighbors(Cell)=>int getNumNeighbors(Cell) METHOD +RefactoringAction 1444385521950 Grid.java RENAME getNumNeighbors(Cell)=>int geNeighbors(Cell) METHOD +RefactoringAction 1444385522960 Grid.java RENAME geNeighbors(Cell)=>int getNeighbors(Cell) METHOD +RefactoringAction 1444385563567 Grid.java RENAME getNeighbors(Cell)=>int getNumNeighbors(Cell) METHOD +RefactoringAction 1444385567488 Grid.java RENAME getNumNeighbors(Cell)=>int getNeighbors(Cell) METHOD +EditAction 1444385569490 TestGrid.java 817 2 12 2 +CompilationAction 1444385572727 TestGrid.java +UnitTestCaseAction 1444385616863 TestGrid.java FAIL +UnitTestSessionAction 1444385616864 TestGrid FAIL +UnitTestCaseAction 1444385630397 TestGrid.java FAIL +UnitTestSessionAction 1444385630398 TestGrid FAIL +EditAction 1444385644616 Grid.java 527 2 5 0 +UnitTestCaseAction 1444385650807 TestGrid.java FAIL +UnitTestSessionAction 1444385650808 TestGrid FAIL +UnitTestCaseAction 1444385694951 TestGrid.java OK +UnitTestSessionAction 1444385694952 TestGrid OK +RefactoringAction 1444385741316 TestGrid.java ADD void testTwoNeightborCellsShouldHaveOneNeighbor()/2 METHOD +RefactoringAction 1444385766354 TestGrid.java RENAME testTwoNeightborCellsShouldHaveOneNeighbor()/2=>void testTwoNeightborCellsOnShouldHaveOneNeighbor() METHOD +RefactoringAction 1444385768366 TestGrid.java RENAME testTwoNeightborCellsOnShouldHaveOneNeighbor()=>void testTwoNeightborCellsOnDiShouldHaveOneNeighbor() METHOD +RefactoringAction 1444385770888 TestGrid.java RENAME testTwoNeightborCellsOnDiShouldHaveOneNeighbor()=>void testTwoNeightborCellsOnDifferentShouldHaveOneNeighbor() METHOD +RefactoringAction 1444385772397 TestGrid.java RENAME testTwoNeightborCellsOnDifferentShouldHaveOneNeighbor()=>void testTwoNeightborCellsOnDifferentRowShouldHaveOneNeighbor() METHOD +RefactoringAction 1444385773407 TestGrid.java RENAME testTwoNeightborCellsOnDifferentRowShouldHaveOneNeighbor()=>void testTwoNeightborCellsOnDifferentRowsShouldHaveOneNeighbor() METHOD +EditAction 1444385776507 TestGrid.java 1154 3 19 3 +UnitTestCaseAction 1444385780901 TestGrid.java FAIL +UnitTestSessionAction 1444385780902 TestGrid.testTwoNeightborCellsOnDifferentRowsShouldHaveOneNeighbor FAIL +UnitTestCaseAction 1444385871729 TestGrid.java OK +UnitTestSessionAction 1444385871731 TestGrid OK +EditAction 1444386761596 TestGrid.java 1198 3 19 3 +UnitTestCaseAction 1444386766376 TestCell.java OK +UnitTestSessionAction 1444386766377 TestCell.testDeadCellWithNoLiveNeighborsShouldLive OK +UnitTestCaseAction 1444386774177 TestCell.java OK +UnitTestSessionAction 1444386774179 TestCell.testDeadCellWithNoLiveNeighborsShouldLive OK +UnitTestCaseAction 1444386784599 TestCell.java OK +UnitTestSessionAction 1444386784600 TestSudokuVerifier OK diff --git a/.besouro/2015100912171338/besouroEpisodes.txt b/.besouro/2015100912171338/besouroEpisodes.txt new file mode 100644 index 0000000..d0701fe --- /dev/null +++ b/.besouro/2015100912171338/besouroEpisodes.txt @@ -0,0 +1,108 @@ +1444382465617 refactoring 2B 231 true +1444382465618 refactoring 2B 231 true +1444382465619 refactoring 2B 231 true +1444382465620 refactoring 2B 231 true +1444382465621 regression 1 231 true +1444382515567 test-addition 1 7 true +1444383022776 test-addition 2 474 true +1444383022777 test-addition 2 474 true +1444383022778 test-addition 1 474 true +1444383022779 test-addition 2 474 true +1444383022780 test-addition 2 474 true +1444383022781 test-addition 1 474 true +1444383512008 refactoring 3 467 true +1444383512009 refactoring 3 467 true +1444383512010 refactoring 3 467 true +1444383512011 refactoring 3 467 true +1444383512012 refactoring 3 467 true +1444383512013 refactoring 3 467 true +1444383512014 refactoring 3 467 true +1444383512015 refactoring 3 467 true +1444383512016 refactoring 3 467 true +1444383512017 refactoring 3 467 true +1444383512018 refactoring 3 467 true +1444383512019 refactoring 3 467 true +1444383512020 refactoring 3 467 true +1444383512021 refactoring 3 467 true +1444383512022 refactoring 3 467 true +1444383512023 refactoring 3 467 true +1444383512024 refactoring 3 467 true +1444383512025 refactoring 3 467 true +1444383512026 refactoring 3 467 true +1444383512027 refactoring 3 467 true +1444383512028 refactoring 3 467 true +1444383512029 refactoring 3 467 true +1444383512030 refactoring 3 467 true +1444383512031 refactoring 3 467 true +1444383512032 refactoring 3 467 true +1444383512033 refactoring 3 467 true +1444383512034 refactoring 3 467 true +1444383512035 refactoring 3 467 true +1444383512036 refactoring 3 467 true +1444383512037 refactoring 3 467 true +1444383512038 refactoring 3 467 true +1444383512039 refactoring 3 467 true +1444383512040 refactoring 3 467 true +1444383512041 refactoring 3 467 true +1444383512042 refactoring 3 467 true +1444383512043 refactoring 3 467 true +1444383512044 refactoring 3 467 true +1444383512045 refactoring 3 467 true +1444383512046 refactoring 3 467 true +1444383512047 refactoring 3 467 true +1444383512048 refactoring 3 467 true +1444383512049 refactoring 3 467 true +1444383512050 refactoring 3 467 true +1444383512051 refactoring 3 467 true +1444383512052 refactoring 3 467 true +1444383512053 refactoring 3 467 true +1444383512054 refactoring 3 467 true +1444383512055 refactoring 3 467 true +1444383512056 refactoring 3 467 true +1444383512057 refactoring 3 467 true +1444383512058 refactoring 3 467 true +1444383512059 refactoring 3 467 true +1444383512060 refactoring 3 467 true +1444383512061 refactoring 3 467 true +1444383512062 refactoring 3 467 true +1444383512063 refactoring 3 467 true +1444383512064 refactoring 3 467 true +1444383512065 refactoring 3 467 true +1444383512066 refactoring 3 467 true +1444383512067 refactoring 3 467 true +1444383512068 refactoring 3 467 true +1444383512069 refactoring 3 467 true +1444383512070 refactoring 3 467 true +1444383512071 refactoring 3 467 true +1444383645589 test-first 2 93 true +1444385694952 test-first 1 2042 true +1444385694953 test-first 1 2042 true +1444385694954 test-first 1 2042 true +1444385694955 test-first 1 2042 true +1444385694956 test-first 1 2042 true +1444385694957 test-first 1 2042 true +1444385694958 test-first 1 2042 true +1444385694959 test-first 1 2042 true +1444385694960 test-first 1 2042 true +1444385694961 test-first 1 2042 true +1444385694962 test-first 1 2042 true +1444385694963 test-first 1 2042 true +1444385694964 test-first 1 2042 true +1444385694965 test-first 1 2042 true +1444385694966 test-first 1 2042 true +1444385694967 test-first 1 2042 true +1444385694968 test-first 1 2042 true +1444385694969 test-first 1 2042 true +1444385694970 test-first 1 2042 true +1444385694971 test-first 1 2042 true +1444385694972 test-first 1 2042 true +1444385694973 test-first 1 2042 true +1444385694974 test-first 1 2042 true +1444385694975 test-first 1 2042 true +1444385871731 test-addition 2 130 true +1444385871732 test-addition 1 130 true +1444385871733 test-addition 2 130 true +1444385871734 test-addition 1 130 true +1444386766377 regression 1 4 true +1444386774179 regression 1 0 true +1444386784600 regression 1 0 true diff --git a/.besouro/2015100912171338/disagreements.txt b/.besouro/2015100912171338/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/2015100912171338/randomHeuristicEpisodes.txt b/.besouro/2015100912171338/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..f5cb768 --- /dev/null +++ b/.besouro/2015100912171338/randomHeuristicEpisodes.txt @@ -0,0 +1,10 @@ +1444382465617 refactoring 2B 231 false +1444382515567 test-addition 1 7 true +1444383022776 test-addition 2 474 false +1444383512008 refactoring 3 467 true +1444383645589 test-first 2 93 true +1444385694952 test-first 1 2042 true +1444385871731 test-addition 2 130 false +1444386766377 regression 1 4 false +1444386774179 regression 1 0 true +1444386784600 regression 1 0 true diff --git a/.besouro/2015100912171338/userComments.txt b/.besouro/2015100912171338/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/2015100912171338/zorroEpisodes.txt b/.besouro/2015100912171338/zorroEpisodes.txt new file mode 100644 index 0000000..ede7023 --- /dev/null +++ b/.besouro/2015100912171338/zorroEpisodes.txt @@ -0,0 +1,10 @@ +1444382465617 refactoring 2B 231 true +1444382515567 test-addition 1 49 true +1444383022776 test-addition 2 507 true +1444383512008 refactoring 3 489 true +1444383645589 test-first 2 133 true +1444385694952 test-first 1 2049 true +1444385871731 test-addition 2 176 true +1444386766377 regression 1 894 true +1444386774179 regression 1 7 true +1444386784600 regression 1 10 true diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java index b66e9c8..0ce51f8 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java @@ -1,5 +1,77 @@ package org.unioulu.tol.sqatlab.gameoflife; public class Cell { + String state; + int x; + int y; + + public Cell(String initialState) { + this.state = initialState; + } + public Cell(int x, int y) { + this.x = x; + this.y = y; + } + + + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public void nextIteration(int numberOfLiveCells) { + if (state.equals("Alive") && numberOfLiveCells < 2){ + state = "Dead"; + }else{ + state = "Alive"; + } + } + + public String getState() { + return this.state; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((state == null) ? 0 : state.hashCode()); + result = prime * result + x; + result = prime * result + y; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Cell other = (Cell) obj; + if (state == null) { + if (other.state != null) + return false; + } else if (!state.equals(other.state)) + return false; + if (x != other.x) + return false; + if (y != other.y) + return false; + return true; + } } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java index 19dbf0b..c1fce1d 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java @@ -1,5 +1,29 @@ package org.unioulu.tol.sqatlab.gameoflife; +import java.util.HashSet; +import java.util.Set; + public class Grid { + private Set cells = new HashSet<>(); + + public int getNumNeighbors(Cell cell) { + int numNeighbors = 0; + Set neigborhood = new HashSet(); + + for(int dx=-1;dx<=1;dx++){ + for(int dy =-1;dy<=1;dy++){ + Cell neighbor = new Cell(cell.x + dx, cell.y + dy); + if(cells.contains(neighbor)){ + numNeighbors++; + } + } + } + return numNeighbors-1; + } + + public void addCell(Cell cell) { + cells.add(cell); + } + } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java index d8de09e..aa1b07f 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java @@ -3,12 +3,34 @@ 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 testLiveCellWithNoNeighborsShouldDie() { + Cell cell = new Cell("Alive"); + + cell.nextIteration(0); + + assertEquals("Dead", cell.getState()); + } + + @Test + public void testLiveCellWithTwoNeighborsShouldLive() { + Cell cell = new Cell("Alive"); + + cell.nextIteration(2); + + assertEquals("Alive", cell.getState()); } + @Test + public void testDeadCellWithNoLiveNeighborsShouldLive() { + Cell cell = new Cell("Alive"); + + cell.nextIteration(2); + + assertEquals("Alive", cell.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..9600b6f 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java @@ -2,12 +2,55 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.unioulu.tol.sqatlab.gameoflife.Cell; +import org.unioulu.tol.sqatlab.gameoflife.Grid; public class TestGrid { @Test - public void test() { - fail("Not yet implemented"); + public void testSingleCellOnGridHasNoNeighbors() { + //arrange + Grid grid = new Grid(); + Cell cell = new Cell(0,0); + + grid.addCell(cell); + + int numNeighbors = grid.getNumNeighbors(cell); + + assertEquals(0, numNeighbors); + } + + @Test + public void testTwoNeightborCellsShouldHaveOneNeighbor() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,1); + + grid.addCell(cell1); + grid.addCell(cell2); + + int numNeighbors = grid.getNumNeighbors(cell1); + + assertEquals(1, numNeighbors); } - + + @Test + public void testTwoNeightborCellsOnDifferentRowsShouldHaveOneNeighbor() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(1,0); + + grid.addCell(cell1); + grid.addCell(cell2); + + int numNeighbors = grid.getNumNeighbors(cell1); + + assertEquals(1, numNeighbors); + } + + //adding State and live neighbor + + }