doodle/lib/render/point_test.go
Noah Petherbridge a316bafb12 Reorganize the package layout
Move all Doodle source code into the src/ subpackage and move the
publicly shareable stuff into lib/, for example lib/ui and lib/render.

This cleans up the git root and helps make the Doodle UI library more
easily publishable as a separate open source project. Currently both
lib/ui and lib/render import one or two things from doodle/src that need
to be broken apart.
2018-12-30 14:22:50 -08:00

61 lines
1020 B
Go

package render_test
import (
"strconv"
"testing"
"git.kirsle.net/apps/doodle/lib/render"
)
func TestPointInside(t *testing.T) {
type testCase struct {
rect render.Rect
p render.Point
shouldPass bool
}
tests := []testCase{
testCase{
rect: render.Rect{
X: 0,
Y: 0,
W: 500,
H: 500,
},
p: render.NewPoint(128, 256),
shouldPass: true,
},
testCase{
rect: render.Rect{
X: 100,
Y: 80,
W: 40,
H: 60,
},
p: render.NewPoint(128, 256),
shouldPass: false,
},
testCase{
// true values when debugging why Doodads weren't
// considered inside the viewport.
rect: render.Rect{
X: 0,
Y: -232,
H: 874,
W: 490,
},
p: render.NewPoint(509, 260),
shouldPass: true,
},
}
for _, test := range tests {
if test.p.Inside(test.rect) != test.shouldPass {
t.Errorf("Failed: %s inside %s should be %s",
test.p,
test.rect,
strconv.FormatBool(test.shouldPass),
)
}
}
}