-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathimage_test.go
46 lines (37 loc) · 1 KB
/
image_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
package main
import "testing"
func TestMax(t *testing.T) {
var want float64 = 5
have := max(1, 2, 3, 4, 5)
if want != have {
t.Errorf("Max number mismatch. Want: %v, Have: %v\n", want, have)
}
}
func TestScale(t *testing.T) {
var whratio float64
var want float64
// 4x4 image fitting in a 2x2 terminal
imgW, imgH, termW, termH := 4, 4, 2, 2
whratio = 1
want = 2
have := scale(imgW, imgH, termW, termH, whratio)
if want != have {
t.Errorf("Image scale mismatch. Want: %v, Have: %v\n", want, have)
}
// 2x2 image fitting in a 4x4 terminal
imgW, imgH, termW, termH = 2, 2, 4, 4
whratio = 1
want = 1
have = scale(imgW, imgH, termW, termH, whratio)
if want != have {
t.Errorf("Image scale mismatch. Want: %v, Have: %v\n", want, have)
}
// 4x4 image fitting in a 2x1 terminal, with whratio = 2
imgW, imgH, termW, termH = 4, 4, 2, 1
whratio = 2
want = 2
have = scale(imgW, imgH, termW, termH, whratio)
if want != have {
t.Errorf("Image scale mismatch. Want: %v, Have: %v\n", want, have)
}
}