diff --git a/.besouro/20151009120851591/actions.txt b/.besouro/20151009120851591/actions.txt new file mode 100644 index 0000000..9ce9ede --- /dev/null +++ b/.besouro/20151009120851591/actions.txt @@ -0,0 +1,124 @@ +FileOpenedAction 1444381731929 Cell.java 68 0 0 0 +FileOpenedAction 1444382042814 TestCell.java 200 1 1 0 +FileOpenedAction 1444382044824 TestGrid.java 199 1 1 0 +RefactoringAction 1444382154363 TestCell.java RENAME test()=>void testLiveCell() METHOD +RefactoringAction 1444382159384 TestCell.java RENAME testLiveCell()=>void testLiveCellWithNoNei() METHOD +RefactoringAction 1444382161903 TestCell.java RENAME testLiveCellWithNoNei()=>void testLiveCellWithNoNeighbors() METHOD +RefactoringAction 1444382163920 TestCell.java RENAME testLiveCellWithNoNeighbors()=>void testLiveCellWithNoNeighborsS() METHOD +RefactoringAction 1444382166938 TestCell.java RENAME testLiveCellWithNoNeighborsS()=>void testLiveCellWithNoNeighborsShouldDie() METHOD +RefactoringAction 1444382343810 TestCell.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444382375514 Cell.java ADD Cell() METHOD +RefactoringAction 1444382400658 Cell.java ADD void nextIteration() METHOD +RefactoringAction 1444382407831 Cell.java ADD Object getState() METHOD +RefactoringAction 1444382454762 Cell.java ADD Cell(String) METHOD +RefactoringAction 1444382499474 Cell.java ADD String state FIELD +RefactoringAction 1444382527942 TestCell.java ADD void testLiveCellWithNoNeighborsShouldDie()/2 METHOD +RefactoringAction 1444382667364 TestCell.java RENAME testLiveCellWithNoNeighborsShouldDie()/2=>void testLiveCellTwoNeigh() METHOD +RefactoringAction 1444382669382 TestCell.java RENAME testLiveCellTwoNeigh()=>void testLiveCellTwoNeighbors() METHOD +RefactoringAction 1444382672400 TestCell.java RENAME testLiveCellTwoNeighbors()=>void testLiveCellTwoNeighborsShouldLive() METHOD +EditAction 1444382684458 Cell.java 317 4 2 0 +EditAction 1444382687826 TestCell.java 633 2 8 2 +RefactoringAction 1444382796684 Cell.java RENAME nextIteration()=>void nextIteration(int) METHOD +RefactoringAction 1444382802057 Cell.java RENAME nextIteration(int)=>void nextIteration() METHOD +RefactoringAction 1444382804068 Cell.java RENAME nextIteration()=>void nextIteration(int) METHOD +EditAction 1444382964926 TestCell.java 637 2 7 2 +EditAction 1444383059188 TestCell.java 640 2 6 2 +UnitTestCaseAction 1444383064879 TestCell.java OK +UnitTestSessionAction 1444383064882 TestCell OK +UnitTestCaseAction 1444383083295 TestCell.java OK +UnitTestSessionAction 1444383083296 TestCell OK +RefactoringAction 1444383214260 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444383223076 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Grid IMPORT +RefactoringAction 1444383396542 Cell.java ADD Cell(int, int) METHOD +RefactoringAction 1444383415717 Cell.java ADD int x FIELD +RefactoringAction 1444383415718 Cell.java ADD int y FIELD +FileOpenedAction 1444383466155 Grid.java 68 0 0 0 +RefactoringAction 1444383500167 Grid.java ADD Grid() METHOD +RefactoringAction 1444383512726 TestGrid.java RENAME test()=>void testSi() METHOD +RefactoringAction 1444383517240 TestGrid.java RENAME testSi()=>void testSingleCellOn() METHOD +RefactoringAction 1444383522755 TestGrid.java RENAME testSingleCellOn()=>void testSingleCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383531536 Grid.java ADD int getNeighbors(Cell) METHOD +RefactoringAction 1444383585118 Grid.java ADD void addCell(Cell) METHOD +RefactoringAction 1444383716046 TestGrid.java ADD void testSingleCellOnGridHasNoNeighbors()/2 METHOD +RefactoringAction 1444383724063 TestGrid.java RENAME testSingleCellOnGridHasNoNeighbors()/2=>void testTwo() METHOD +RefactoringAction 1444383726080 TestGrid.java RENAME testTwo()=>void testTwoNeigh() METHOD +RefactoringAction 1444383727596 TestGrid.java RENAME testTwoNeigh()=>void testTwoNeighbors() METHOD +RefactoringAction 1444383796196 TestGrid.java RENAME testTwoNeighbors()=>void testTwoNeighborsC() METHOD +RefactoringAction 1444383797713 TestGrid.java RENAME testTwoNeighborsC()=>void testTwoNeighborsCells() METHOD +RefactoringAction 1444383800230 TestGrid.java RENAME testTwoNeighborsCells()=>void testTwoNeighborsCellsS() METHOD +RefactoringAction 1444383802245 TestGrid.java RENAME testTwoNeighborsCellsS()=>void testTwoNeighborsCellsShould() METHOD +RefactoringAction 1444383807763 TestGrid.java RENAME testTwoNeighborsCellsShould()=>void testTwoNeighborsCellsShouldHaveOne() METHOD +RefactoringAction 1444383812279 TestGrid.java RENAME testTwoNeighborsCellsShouldHaveOne()=>void testTwoNeighborsCellsShouldHaveOneNeighbor() METHOD +EditAction 1444383843268 TestGrid.java 760 2 12 2 +EditAction 1444383846261 Grid.java 197 3 1 0 +EditAction 1444384408011 Grid.java 197 3 1 0 +UnitTestCaseAction 1444384476954 TestGrid.java FAIL +UnitTestSessionAction 1444384476956 TestGrid FAIL +RefactoringAction 1444384563939 Grid.java ADD Set<> cells FIELD +RefactoringAction 1444384594660 Grid.java ADD import java.util.HashSet IMPORT +RefactoringAction 1444384598129 Grid.java ADD import java.util.Set IMPORT +RefactoringAction 1444384717061 Cell.java ADD int hashCode() METHOD +RefactoringAction 1444384717062 Cell.java ADD boolean equals(Object) METHOD +RefactoringAction 1444384960243 Cell.java ADD int get FIELD +RefactoringAction 1444384964267 Cell.java RENAME get=>int getX FIELD +RefactoringAction 1444384965791 Cell.java RENAME getX=>int getX() METHOD +RefactoringAction 1444384993491 Cell.java ADD int getX()/2 METHOD +RefactoringAction 1444384996016 Cell.java RENAME getX()/2=>int getY() METHOD +EditAction 1444385041968 Grid.java 353 3 3 0 +EditAction 1444385134911 Grid.java 362 3 3 0 +RefactoringAction 1444385505863 Grid.java RENAME getNeighbors(Cell)=>int getNumOfNeighbors(Cell) METHOD +EditAction 1444385647505 TestGrid.java 770 2 12 2 +UnitTestCaseAction 1444385654688 TestGrid.java FAIL +UnitTestSessionAction 1444385654692 TestGrid FAIL +RefactoringAction 1444385844489 Grid.java ADD int dx FIELD +RefactoringAction 1444386253884 Grid.java REMOVE dx FIELD +CompilationAction 1444386305467 Grid.java +CompilationAction 1444386317135 Grid.java +UnitTestCaseAction 1444386318135 TestGrid.java OK +UnitTestSessionAction 1444386318136 TestGrid OK +FileOpenedAction 1444386759799 Cell.java 1232 9 21 0 +RefactoringAction 1444386904582 TestCell.java ADD void testLiveCellTwoNeighborsShouldLive()/2 METHOD +RefactoringAction 1444386909599 TestCell.java RENAME testLiveCellTwoNeighborsShouldLive()/2=>void testLiveCellThreeNeighborsShouldLive() METHOD +EditAction 1444386923183 TestCell.java 869 3 9 3 +UnitTestCaseAction 1444386932080 TestCell.java OK +UnitTestSessionAction 1444386932081 TestCell OK +UnitTestCaseAction 1444387083826 TestCell.java OK +UnitTestSessionAction 1444387083827 TestCell OK +RefactoringAction 1444387101669 TestCell.java ADD void testLiveCellThreeNeighborsShouldLive()/2 METHOD +RefactoringAction 1444387116687 TestCell.java RENAME testLiveCellThreeNeighborsShouldLive()/2=>void testLiveCellMoreThanThreeNeighborsShouldLive() METHOD +RefactoringAction 1444387121204 TestCell.java RENAME testLiveCellMoreThanThreeNeighborsShouldLive()=>void testLiveCellMoreThanThreeNeighborsShouldDie() METHOD +EditAction 1444387164688 TestCell.java 1105 4 12 4 +UnitTestCaseAction 1444387167780 TestCell.java FAIL +UnitTestSessionAction 1444387167781 TestCell FAIL +EditAction 1444387174643 TestCell.java 1104 4 12 4 +UnitTestCaseAction 1444387177940 TestCell.java OK +UnitTestSessionAction 1444387177940 TestCell OK +RefactoringAction 1444387218351 TestCell.java ADD void testLiveCellMoreThanThreeNeighborsShouldDie()/2 METHOD +RefactoringAction 1444387223370 TestCell.java RENAME testLiveCellMoreThanThreeNeighborsShouldDie()/2=>void testDeadCellMoreThanThreeNeighborsShouldDie() METHOD +RefactoringAction 1444387229388 TestCell.java RENAME testDeadCellMoreThanThreeNeighborsShouldDie()=>void testDeadCellThreeNeighborsShouldDie() METHOD +RefactoringAction 1444387233907 TestCell.java RENAME testDeadCellThreeNeighborsShouldDie()=>void testDeadCellThreeNeighborsShouldLive() METHOD +EditAction 1444387262177 TestCell.java 1204 5 15 5 +UnitTestCaseAction 1444387265352 TestCell.java OK +UnitTestSessionAction 1444387265353 TestCell OK +UnitTestCaseAction 1444387373886 TestCell.java OK +UnitTestSessionAction 1444387373887 TestCell OK +EditAction 1444387382070 TestCell.java 1203 5 15 5 +UnitTestCaseAction 1444387385187 TestCell.java FAIL +UnitTestSessionAction 1444387385188 TestCell FAIL +EditAction 1444387390465 TestCell.java 1204 5 15 5 +UnitTestCaseAction 1444387395305 TestCell.java OK +UnitTestSessionAction 1444387395306 TestCell OK +RefactoringAction 1444387434615 TestCell.java ADD void testLiveCellMoreThanThreeNeighborsShouldDie()/2 METHOD +RefactoringAction 1444387442136 TestCell.java RENAME testLiveCellMoreThanThreeNeighborsShouldDie()/2=>void testLiveCellLessThanThreeNeighborsShouldDie() METHOD +RefactoringAction 1444387447156 TestCell.java RENAME testLiveCellLessThanThreeNeighborsShouldDie()=>void testLiveCellLessThanTNeighborsShouldDie() METHOD +RefactoringAction 1444387449675 TestCell.java RENAME testLiveCellLessThanTNeighborsShouldDie()=>void testLiveCellLessThanTwoNeighborsShouldDie() METHOD +EditAction 1444387476092 TestCell.java 1405 6 18 6 +UnitTestCaseAction 1444387479171 TestCell.java OK +UnitTestSessionAction 1444387479172 TestCell OK +EditAction 1444387577706 Cell.java 1383 9 21 0 +EditAction 1444387580729 TestCell.java 1406 6 18 6 +UnitTestCaseAction 1444387585818 TestCell.java FAIL +UnitTestSessionAction 1444387585819 TestCell FAIL +EditAction 1444387590854 TestCell.java 1405 6 18 6 +UnitTestCaseAction 1444387595920 TestCell.java OK +UnitTestSessionAction 1444387595921 TestCell OK diff --git a/.besouro/20151009120851591/besouroEpisodes.txt b/.besouro/20151009120851591/besouroEpisodes.txt new file mode 100644 index 0000000..6f5036e --- /dev/null +++ b/.besouro/20151009120851591/besouroEpisodes.txt @@ -0,0 +1,21 @@ +1444383064882 test-first 4 1332 true +1444383064883 test-last 1 1332 false +1444383083296 regression 1 0 true +1444386318136 test-first 3 3103 true +1444386318137 test-first 3 3103 true +1444386318138 test-first 3 3103 true +1444386318139 test-first 3 3103 true +1444386932081 test-addition 1 172 true +1444386932082 test-addition 1 172 true +1444387083827 regression 1 0 true +1444387177940 test-addition 2 76 true +1444387177941 test-addition 1 76 true +1444387177942 test-addition 2 76 true +1444387177943 test-addition 1 76 true +1444387265353 test-addition 1 47 true +1444387265354 test-addition 1 47 true +1444387373887 regression 1 0 true +1444387395306 regression 2 13 true +1444387479172 test-addition 1 44 true +1444387479173 test-addition 1 44 true +1444387595921 refactoring 2A 18 true diff --git a/.besouro/20151009120851591/disagreements.txt b/.besouro/20151009120851591/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009120851591/randomHeuristicEpisodes.txt b/.besouro/20151009120851591/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..b64cdb6 --- /dev/null +++ b/.besouro/20151009120851591/randomHeuristicEpisodes.txt @@ -0,0 +1,11 @@ +1444383064882 test-first 4 1332 true +1444383083296 regression 1 0 true +1444386318136 test-first 3 3103 true +1444386932081 test-addition 1 172 false +1444387083827 regression 1 0 true +1444387177940 test-addition 2 76 true +1444387265353 test-addition 1 47 true +1444387373887 regression 1 0 false +1444387395306 regression 2 13 true +1444387479172 test-addition 1 44 true +1444387595921 refactoring 2A 18 false diff --git a/.besouro/20151009120851591/userComments.txt b/.besouro/20151009120851591/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009120851591/zorroEpisodes.txt b/.besouro/20151009120851591/zorroEpisodes.txt new file mode 100644 index 0000000..bf590c5 --- /dev/null +++ b/.besouro/20151009120851591/zorroEpisodes.txt @@ -0,0 +1,11 @@ +1444383064882 test-first 4 1332 true +1444383083296 regression 1 18 true +1444386318136 test-first 3 3234 true +1444386932081 test-addition 1 613 true +1444387083827 regression 1 151 true +1444387177940 test-addition 2 94 true +1444387265353 test-addition 1 87 true +1444387373887 regression 1 108 true +1444387395306 regression 2 21 true +1444387479172 test-addition 1 83 true +1444387595921 refactoring 2A 116 true diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java index b66e9c8..6a17f0a 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java @@ -2,4 +2,84 @@ public class Cell { + String state; + int x; + int y; + + public Cell(){ + + } + + 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 int getY(){ + return y; + } + + + public void nextIteration(int numOfLiveCells) { + if (state == "Dead" && numOfLiveCells == 3){ + state = "Alive"; + } + else if (state == "Alive" && numOfLiveCells < 2){ + state = "Dead"; + } + else if (state == "Alive" && numOfLiveCells > 3){ + state = "Dead"; + } + else{ + state = "Alive"; + } + } + + + + @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; + } + + public String getState() { + // TODO Auto-generated method stub + return this.state; + } + } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java index 19dbf0b..4b649f6 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java @@ -1,5 +1,41 @@ package org.unioulu.tol.sqatlab.gameoflife; +import java.util.HashSet; +import java.util.Set; + public class Grid { + private Set cells = new HashSet<>(); + + public Grid(){ + + } + + public int getNumOfNeighbors(Cell cell) { + int numNeighbors = 0; + 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..4e6ff9d 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java @@ -3,12 +3,81 @@ 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() { + //arrange + Cell cell= new Cell("Alive"); + // + cell.nextIteration(0); + + //assert + assertEquals("Dead", cell.getState()); + //fail("Not yet implemented"); } + + @Test + public void testLiveCellTwoNeighborsShouldLive() { + //arrange + Cell cell= new Cell("Alive"); + // + cell.nextIteration(2); + + //assert + assertEquals("Alive", cell.getState()); + + } + + @Test + public void testLiveCellThreeNeighborsShouldLive() { + //arrange + Cell cell= new Cell("Alive"); + // + cell.nextIteration(3); + + //assert + assertEquals("Alive", cell.getState()); + + } + + @Test + public void testLiveCellMoreThanThreeNeighborsShouldDie() { + //arrange + Cell cell= new Cell("Alive"); + // + cell.nextIteration(4); + + //assert + assertEquals("Dead", cell.getState()); + + } + + @Test + public void testDeadCellThreeNeighborsShouldLive() { + //arrange + Cell cell= new Cell("Dead"); + // + cell.nextIteration(3); + + //assert + assertEquals("Alive", cell.getState()); + + } + + @Test + public void testLiveCellLessThanTwoNeighborsShouldDie() { + //arrange + Cell cell= new Cell("Alive"); + // + cell.nextIteration(1); + + //assert + assertEquals("Dead", 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..9355668 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java @@ -2,12 +2,39 @@ 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() { + Grid grid = new Grid(); + Cell cell = new Cell(0,0); + + + grid.addCell(cell); + + + int numNeighbors = grid.getNumOfNeighbors(cell); + + assertEquals(0, numNeighbors); + + } + + @Test + public void testTwoNeighborsCellsShouldHaveOneNeighbor() { + 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.getNumOfNeighbors(cell1); + + assertEquals(1, numNeighbors); + } }