package imagefile import "testing" func TestFitDimensionsPreservesAspectAndDoesNotUpscale(t *testing.T) { for _, c := range []struct{ w, h, max, wantW, wantH int }{{320, 200, 256, 256, 160}, {1, 1, 256, 1, 1}, {1, 400, 256, 1, 256}, {400, 1, 256, 256, 1}, {200, 320, 256, 160, 256}, {1280, 1280, 1280, 1280, 1280}} { w, h := FitDimensions(c.w, c.h, c.max) if w != c.wantW || h != c.wantH { t.Errorf("%+v: got %dx%d", c, w, h) } } }