Skip to content

Instantly share code, notes, and snippets.

@mpaltun
Created December 8, 2012 15:10
Show Gist options
  • Save mpaltun/4240688 to your computer and use it in GitHub Desktop.
Save mpaltun/4240688 to your computer and use it in GitHub Desktop.
lifetest
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