Adding vert and horz tests
This commit is contained in:
parent
d2d1f03c32
commit
8792d4436c
|
@ -1002,6 +1002,18 @@ func TestLine_Closest(t *testing.T) {
|
|||
args: args{v: pixel.V(20, 20)},
|
||||
want: pixel.V(10, 10),
|
||||
},
|
||||
{
|
||||
name: "Vertical line",
|
||||
fields: fields{A: pixel.V(0, -10), B: pixel.V(0, 10)},
|
||||
args: args{v: pixel.V(-1, 0)},
|
||||
want: pixel.V(0, 0),
|
||||
},
|
||||
{
|
||||
name: "Horizontal line",
|
||||
fields: fields{A: pixel.V(-10, 0), B: pixel.V(10, 0)},
|
||||
args: args{v: pixel.V(0, -1)},
|
||||
want: pixel.V(0, 0),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -1267,36 +1279,42 @@ func TestLine_IntersectRect(t *testing.T) {
|
|||
args args
|
||||
want pixel.Vec
|
||||
}{
|
||||
//{
|
||||
// name: "Line through rect vertically",
|
||||
// fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)},
|
||||
// args: args{r: pixel.R(-1, 1, 5, 5)},
|
||||
// want: pixel.V(-1, 0),
|
||||
//},
|
||||
//{
|
||||
// name: "Line through rect horizontally",
|
||||
// fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)},
|
||||
// args: args{r: pixel.R(1, 0, 5, 5)},
|
||||
// want: pixel.V(0, -1),
|
||||
//},
|
||||
//{
|
||||
// name: "Line through rect diagonally bottom and left edges",
|
||||
// fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)},
|
||||
// args: args{r: pixel.R(0, 2, 3, 3)},
|
||||
// want: pixel.V(-1, 1),
|
||||
//},
|
||||
//{
|
||||
// name: "Line through rect diagonally top and right edges",
|
||||
// fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)},
|
||||
// args: args{r: pixel.R(5, 0, 8, 3)},
|
||||
// want: pixel.V(-2.5, -2.5),
|
||||
//},
|
||||
//{
|
||||
// name: "Line with not rect intersect",
|
||||
// fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)},
|
||||
// args: args{r: pixel.R(20, 20, 21, 21)},
|
||||
// want: pixel.ZV,
|
||||
//},
|
||||
{
|
||||
name: "Line through rect vertically",
|
||||
fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)},
|
||||
args: args{r: pixel.R(-1, 1, 5, 5)},
|
||||
name: "Line intersects at 0,0",
|
||||
fields: fields{A: pixel.V(0, -10), B: pixel.V(0, 10)},
|
||||
args: args{r: pixel.R(-1, 0, 2, 2)},
|
||||
want: pixel.V(-1, 0),
|
||||
},
|
||||
{
|
||||
name: "Line through rect horizontally",
|
||||
fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)},
|
||||
args: args{r: pixel.R(1, 0, 5, 5)},
|
||||
want: pixel.V(0, -1),
|
||||
},
|
||||
{
|
||||
name: "Line through rect diagonally bottom and left edges",
|
||||
fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)},
|
||||
args: args{r: pixel.R(0, 2, 3, 3)},
|
||||
want: pixel.V(-1, 1),
|
||||
},
|
||||
{
|
||||
name: "Line through rect diagonally top and right edges",
|
||||
fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)},
|
||||
args: args{r: pixel.R(5, 0, 8, 3)},
|
||||
want: pixel.V(-2.5, -2.5),
|
||||
},
|
||||
{
|
||||
name: "Line with not rect intersect",
|
||||
fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)},
|
||||
args: args{r: pixel.R(20, 20, 21, 21)},
|
||||
want: pixel.ZV,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue