示例#1
0
func TestBoard(t *testing.T) {
	board := gol.NewBoard()
	board.SetAlive(gol.NewPoint(2, 3))
	board.SetAlive(gol.NewPoint(0, 3))
	if !board.GetCell(gol.NewPoint(2, 3)).IsAlive() {
		t.Fatal("Expected alive cell on 2,3")
	}
	if board.AliveNeighbors(gol.NewPoint(1, 3)) != 2 {
		t.Fatal("Expected neighbors for 1,3 is 2")
	}
	if board.AliveNeighbors(gol.NewPoint(3, 3)) != 1 {
		t.Fatal("Expected neighbors for 3,3 is 1")
	}
}
示例#2
0
func TestNextBoard(t *testing.T) {
	board := gol.NewBoard()
	board.SetAlive(gol.NewPoint(1, 2))
	board.SetAlive(gol.NewPoint(2, 2))
	board.SetAlive(gol.NewPoint(3, 2))
	next := board.Next()
	if !next.GetCell(gol.NewPoint(2, 1)).IsAlive() {
		t.Fatal("Expected alive cell on 2,1")
	}
	if !next.GetCell(gol.NewPoint(2, 2)).IsAlive() {
		t.Fatal("Expected alive cell on 2,2")
	}
	if !next.GetCell(gol.NewPoint(2, 3)).IsAlive() {
		t.Fatal("Expected alive cell on 2,3")
	}

}