-
Notifications
You must be signed in to change notification settings - Fork 1
/
progress_test.go
59 lines (52 loc) · 1.16 KB
/
progress_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
package goey
import (
"testing"
"bitbucket.org/rj/goey/base"
)
func TestProgressMount(t *testing.T) {
testingMountWidgets(t,
&Progress{Value: 50, Min: 0, Max: 100},
&Progress{Value: 0},
&Progress{Value: 0},
&Progress{Value: 100},
&Slider{Value: 500, Max: 1000},
)
}
func TestProgressClose(t *testing.T) {
testingCloseWidgets(t,
&Progress{Value: 50, Min: 0, Max: 100},
&Progress{Value: 0},
)
}
func TestProgressUpdate(t *testing.T) {
testingUpdateWidgets(t, []base.Widget{
&Progress{Value: 50, Min: 0, Max: 100},
&Progress{Value: 50, Min: 0, Max: 100},
}, []base.Widget{
&Progress{Value: 75, Min: 0, Max: 100},
&Progress{Value: 50, Min: 0, Max: 200},
})
}
func TestProgress_UpdateValue(t *testing.T) {
cases := []struct {
value int
min, max int
out int
}{
{1, 0, 10, 1},
{0, 0, 10, 0},
{10, 0, 10, 10},
{-1, 0, 10, 0},
{11, 0, 10, 10},
{-1, 0, 0, 0},
{11, 0, 0, 0},
{-1, 0, -1, 0},
}
for i, v := range cases {
widget := Progress{Value: v.value, Min: v.min, Max: v.max}
widget.UpdateValue()
if widget.Value != v.out {
t.Errorf("Case %d: .Value does not match, got %d, want %d", i, widget.Value, v.out)
}
}
}