Beispiel #1
0
func TestAliveCell(t *testing.T) {
	cell := gol.NewCell(true)
	if cell.Next(1).IsAlive() {
		t.Fatal("Alive cell with 1 neighbour should die")
	}
	if !cell.Next(2).IsAlive() {
		t.Fatal("Alive cell with 2 neighbour should not die")
	}
	if !cell.Next(3).IsAlive() {
		t.Fatal("Alive cell with 3 neighbour should not die")
	}
}
Beispiel #2
0
func TestDeadCell(t *testing.T) {
	cell := gol.NewCell(false)
	if cell.Next(1).IsAlive() {
		t.Fatal("Dead cell with 1 neighbour should stay dead")
	}
	if cell.Next(4).IsAlive() {
		t.Fatal("Dead cell with 4 neighbour should stay dead")
	}
	if cell.Next(5).IsAlive() {
		t.Fatal("Dead cell with 5 neighbour should stay dead")
	}
	if !cell.Next(3).IsAlive() {
		t.Fatal("Dead cell with 3 neighbour should become alive")
	}
}