-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize_constraints_test.go
70 lines (67 loc) · 1.36 KB
/
resize_constraints_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package icat
import (
"image"
"testing"
)
func Test_resizeFactor(t *testing.T) {
type args struct {
imageBounds image.Rectangle
height int
width int
}
tests := []struct {
name string
args args
want_size int
want_option rune
}{
{
name: "no resize",
args: args{
imageBounds: image.Rect(0, 0, 100, 100),
height: 200,
width: 200,
},
want_size: 0,
want_option: '0',
},
{
name: "resize height",
args: args{
imageBounds: image.Rect(0, 0, 100, 100),
height: 50,
width: 200,
},
want_size: 50,
want_option: 'y',
},
{
name: "resize width",
args: args{
imageBounds: image.Rect(0, 0, 100, 100),
height: 200,
width: 50,
},
want_size: 50,
want_option: 'x',
},
{
name: "resize both x and y",
args: args{
imageBounds: image.Rect(0, 0, 100, 100),
height: 50,
width: 50,
},
want_size: 50,
want_option: 'x',
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got_size, got_option := resizeConstraints(tt.args.imageBounds, tt.args.height, tt.args.width)
if got_size != int(tt.want_size) || got_option != tt.want_option {
t.Errorf("resizeConstraints() = %v, %s, want %v, %s", got_size, string(got_option), tt.want_size, string(tt.want_option))
}
})
}
}