Files
gonum/graph_test.go
2013-07-24 02:41:11 -07:00

49 lines
1.4 KiB
Go

package discrete_test
import (
"github.com/gonum/discrete"
"testing"
)
func TestTileGraph_carving(t *testing.T) {
tg := discrete.NewTileGraph(4, 4, false)
if tg == nil || tg.String() != "▀▀▀▀\n▀▀▀▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Tile graph not generated correctly")
}
tg.SetPassability(0, 1, true)
if tg == nil || tg.String() != "▀ ▀▀\n▀▀▀▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(0, 1, false)
if tg == nil || tg.String() != "▀▀▀▀\n▀▀▀▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(0, 1, true)
if tg == nil || tg.String() != "▀ ▀▀\n▀▀▀▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(0, 2, true)
if tg == nil || tg.String() != "▀ ▀\n▀▀▀▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(1, 2, true)
if tg == nil || tg.String() != "▀ ▀\n▀▀ ▀\n▀▀▀▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(2, 2, true)
if tg == nil || tg.String() != "▀ ▀\n▀▀ ▀\n▀▀ ▀\n▀▀▀▀" {
t.Fatal("Passability set incorrectly")
}
tg.SetPassability(3, 2, true)
if tg == nil || tg.String() != "▀ ▀\n▀▀ ▀\n▀▀ ▀\n▀▀ ▀" {
t.Fatal("Passability set incorrectly")
}
}