28 lines
949 B
Go
28 lines
949 B
Go
package compositor
|
|
|
|
import "testing"
|
|
|
|
func TestTileRect(t *testing.T) {
|
|
W, H := 1920, 1080
|
|
// A 1x1 tile at (0,0) in a 4x4 grid.
|
|
got := TileRect(W, H, 4, 4, 0, 0, 1, 1)
|
|
if got.W != W/4 || got.H != H/4 || got.X != 0 || got.Y != 0 {
|
|
t.Errorf("1x1 top-left: got %+v", got)
|
|
}
|
|
// A tile spanning the full width/height must reach the exact edges.
|
|
full := TileRect(W, H, 4, 4, 0, 0, 4, 4)
|
|
if full.X != 0 || full.Y != 0 || full.W != W || full.H != H {
|
|
t.Errorf("full-span: got %+v want full frame", full)
|
|
}
|
|
// A 3x3 main tile plus a right column: the main reaches 3/4 width, the
|
|
// side tile fills the remainder to the exact right edge.
|
|
main := TileRect(W, H, 4, 4, 0, 0, 3, 4)
|
|
side := TileRect(W, H, 4, 4, 3, 0, 1, 1)
|
|
if main.X+main.W != side.X {
|
|
t.Errorf("main right edge %d should meet side left edge %d", main.X+main.W, side.X)
|
|
}
|
|
if side.X+side.W != W {
|
|
t.Errorf("side tile right edge %d should reach %d", side.X+side.W, W)
|
|
}
|
|
}
|