Files
galaxy-game/client/world/primitive_test.go
T
2026-03-07 19:28:22 +02:00

73 lines
1.4 KiB
Go

package world
import (
"testing"
)
func TestPrimitiveIDs(t *testing.T) {
t.Parallel()
id1 := PrimitiveID(1)
id2 := PrimitiveID(2)
id3 := PrimitiveID(3)
p := Point{Id: id1}
l := Line{Id: id2}
c := Circle{Id: id3}
if got := p.ID(); got != id1 {
t.Fatalf("Point.ID() = %v, want %v", got, id1)
}
if got := l.ID(); got != id2 {
t.Fatalf("Line.ID() = %v, want %v", got, id2)
}
if got := c.ID(); got != id3 {
t.Fatalf("Circle.ID() = %v, want %v", got, id3)
}
}
func TestLineMinMax(t *testing.T) {
t.Parallel()
l := Line{
X1: 7000, Y1: 2000,
X2: 1000, Y2: 9000,
}
if got := l.MinX(); got != 1000 {
t.Fatalf("Line.MinX() = %d, want 1000", got)
}
if got := l.MaxX(); got != 7000 {
t.Fatalf("Line.MaxX() = %d, want 7000", got)
}
if got := l.MinY(); got != 2000 {
t.Fatalf("Line.MinY() = %d, want 2000", got)
}
if got := l.MaxY(); got != 9000 {
t.Fatalf("Line.MaxY() = %d, want 9000", got)
}
}
func TestCircleBounds(t *testing.T) {
t.Parallel()
c := Circle{
X: 4000,
Y: 7000,
Radius: 1500,
}
if got := c.MinX(); got != 2500 {
t.Fatalf("Circle.MinX() = %d, want 2500", got)
}
if got := c.MaxX(); got != 5500 {
t.Fatalf("Circle.MaxX() = %d, want 5500", got)
}
if got := c.MinY(); got != 5500 {
t.Fatalf("Circle.MinY() = %d, want 5500", got)
}
if got := c.MaxY(); got != 8500 {
t.Fatalf("Circle.MaxY() = %d, want 8500", got)
}
}