mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-02 17:27:23 -04:00
07d90e9681
* Fixed nil pointer in Copy() * Position added Added Floor() and String() methods to Vector. Also added Position which declares an embedded Vector2 and returns various forms of it. * Position tests improved
34 lines
496 B
Go
34 lines
496 B
Go
package d2vector
|
|
|
|
import "testing"
|
|
|
|
func TestClone(t *testing.T) {
|
|
v := New(1, 1)
|
|
want := New(1, 1)
|
|
got := v.Clone()
|
|
|
|
if !got.Equals(want) {
|
|
t.Errorf("wanted %s: got %s", want, got)
|
|
}
|
|
}
|
|
|
|
func TestAbs(t *testing.T) {
|
|
v := New(-1, -1)
|
|
want := New(1, 1)
|
|
got := v.Abs()
|
|
|
|
if !got.Equals(want) {
|
|
t.Errorf("wanted %s: got %s", want, got)
|
|
}
|
|
}
|
|
|
|
func TestFloor(t *testing.T) {
|
|
v := New(1.6, 1.6)
|
|
|
|
want := New(1, 1)
|
|
|
|
if !v.Floor().Equals(want) {
|
|
t.Errorf("want %s: got %s", want, v)
|
|
}
|
|
}
|