Created
December 8, 2012 15:10
-
-
Save mpaltun/4240688 to your computer and use it in GitHub Desktop.
lifetest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cr; | |
import static junit.framework.Assert.*; | |
import org.junit.Test; | |
public class LifeTest { | |
public abstract class Cell { | |
public abstract boolean isAliveOnTick(); | |
public abstract void addNeighbour(Cell neighbour); | |
} | |
public class AliveCell extends Cell { | |
@Override | |
public boolean isAliveOnTick() { | |
return true; | |
} | |
@Override | |
public void addNeighbour(Cell neighbour) { | |
} | |
} | |
private class DeadCell extends Cell { | |
@Override | |
public boolean isAliveOnTick() { | |
return true; | |
} | |
@Override | |
public void addNeighbour(Cell neighbour) { | |
} | |
} | |
@Test | |
public void underPopulationAliveHasOneDeadNeighbourTest() { | |
// | |
Cell aliveCell = new AliveCell(); | |
aliveCell.addNeighbour(new DeadCell()); | |
// | |
boolean alive = aliveCell.isAliveOnTick(); | |
// | |
assertFalse(alive); | |
} | |
@Test | |
public void underPopulationAliveHasOneALiveNeighbourTest() { | |
// | |
Cell aliveCell = new AliveCell(); | |
aliveCell.addNeighbour(new DeadCell()); | |
// | |
boolean alive = aliveCell.isAliveOnTick(); | |
// | |
assertFalse(alive); | |
} | |
@Test | |
public void underPopulationAliveHasNoNeighbourTest() { | |
// | |
Cell aliveCell = new AliveCell(); | |
// | |
boolean alive = aliveCell.isAliveOnTick(); | |
// | |
assertFalse(alive); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment