fs storage
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestShortDistance(t *testing.T) {
|
||||
for i, tc := range []struct {
|
||||
w, h uint32
|
||||
x1, y1, x2, y2, d float64
|
||||
}{
|
||||
{10, 10, 0, 0, 5, 5, 7.071},
|
||||
{10, 10, 0, 0, 5.01, 5.01, 7.057},
|
||||
{10, 10, 2, 2, 8, 2, 4.},
|
||||
{10, 10, 8, 7, 1, 7, 3.},
|
||||
} {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
m := Map{Width: tc.w, Height: tc.h}
|
||||
d := m.ShortDistance(Coordinate{tc.x1, tc.y1}, Coordinate{tc.x2, tc.y2})
|
||||
assert.Equal(t, tc.d, util.Fixed3(d))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user