1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-10-15 06:33:46 -04:00
OpenDiablo2/d2common/d2math/d2vector/vector_test.go
danhale-git 07d90e9681
Position struct for managing world coordinates (#540)
* 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
2020-07-04 19:25:53 -04:00

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)
}
}