resource_manager/image/image_test.go

32 lines
805 B
Go
Raw Normal View History

2022-06-13 06:37:16 +00:00
package image_test
import (
"git.bbr-dev.info/brajkovic/resource_manager/image"
"testing"
)
func TestResize(t *testing.T) {
cases := [][]int{
// minX, minY, x, y, newX, newY
{400, 300, 400, 800, 400, 800},
{400, 300, 800, 400, 600, 300},
{1024, 1280, 800, 400, 800, 400},
{400, 300, 800, 100, 800, 100},
{1200, 900, 1600, 1400, 1200, 1050},
}
for _, testCase := range cases {
minX, minY, x, y, newX, newY := destructure(testCase)
rX, rY := image.Resize(minX, minY, x, y)
if rX != newX || rY != newY {
t.Errorf("for (%d, %d, %d, %d)expected (%d, %d) received (%d, %d)", minX, minY, x, y, newX, newY, rX, rY)
}
}
}
func destructure(testCase []int) (minX, minY, x, y, newX, newY int) {
return testCase[0], testCase[1], testCase[2], testCase[3], testCase[4], testCase[5]
}