delaunay/mst working
This commit is contained in:
37
delaunay_test.go
Normal file
37
delaunay_test.go
Normal file
@ -0,0 +1,37 @@
|
||||
package alchemyst_go
|
||||
|
||||
import (
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util/delaunay"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDelaunay(t *testing.T) {
|
||||
|
||||
coords := []types.Coords{
|
||||
{10,10},
|
||||
{10,60},
|
||||
{30,10},
|
||||
{40,20},
|
||||
{60,10},
|
||||
{40,60},
|
||||
}
|
||||
|
||||
expected := []types.Edge{
|
||||
{types.Coords{10, 60}, types.Coords{10, 10}},
|
||||
{types.Coords{30, 10}, types.Coords{40, 20}},
|
||||
{types.Coords{60, 10}, types.Coords{40, 60}},
|
||||
{types.Coords{40, 20}, types.Coords{40, 60}},
|
||||
{types.Coords{10, 10,}, types.Coords{30, 10}},
|
||||
}
|
||||
|
||||
result := delaunay.GetMst(coords, 100, 100)
|
||||
|
||||
for idx, _ := range result {
|
||||
if result[idx] != expected[idx] {
|
||||
t.Errorf("Failed, expected %v. got %v", result[idx], expected[idx])
|
||||
}
|
||||
|
||||
}
|
||||
t.Log("output: ", result)
|
||||
}
|
Reference in New Issue
Block a user