forked from alitto/pond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resizer_test.go
46 lines (33 loc) · 1.07 KB
/
resizer_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 pond
import (
"testing"
)
func TestRatedResizer(t *testing.T) {
resizer := RatedResizer(3)
assertEqual(t, true, resizer.Resize(0, 0, 10))
assertEqual(t, true, resizer.Resize(0, 0, 10))
assertEqual(t, true, resizer.Resize(1, 0, 10))
assertEqual(t, false, resizer.Resize(2, 0, 10))
assertEqual(t, false, resizer.Resize(3, 0, 10))
assertEqual(t, true, resizer.Resize(4, 0, 10))
}
func TestRatedResizerWithRate1(t *testing.T) {
resizer := RatedResizer(1)
assertEqual(t, true, resizer.Resize(0, 0, 10))
assertEqual(t, true, resizer.Resize(1, 0, 10))
assertEqual(t, true, resizer.Resize(2, 0, 10))
}
func TestRatedResizerWithInvalidRate(t *testing.T) {
resizer := RatedResizer(0)
assertEqual(t, true, resizer.Resize(0, 0, 10))
assertEqual(t, true, resizer.Resize(1, 0, 10))
assertEqual(t, true, resizer.Resize(2, 0, 10))
}
func TestPresetRatedResizers(t *testing.T) {
eager := Eager()
balanced := Balanced()
lazy := Lazy()
assertEqual(t, true, eager.Resize(0, 0, 10))
assertEqual(t, true, balanced.Resize(0, 0, 10))
assertEqual(t, true, lazy.Resize(0, 0, 10))
}