-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus_test.go
79 lines (62 loc) · 1.49 KB
/
status_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
71
72
73
74
75
76
77
78
79
package ggping_test
import (
"github.com/kwQt/ggping"
"testing"
)
func TestStatus_GetAll(t *testing.T) {
t.Run("Return all values (all fit in capacity)", func(t *testing.T) {
// setup
status := ggping.NewStatus(3)
status.Update(1)
status.Update(2)
expect := []float64{1, 2}
// test & verify
for i, v := range status.GetAll() {
if v != expect[i] {
t.Errorf("expect: %g, actual: %g", expect[i], v)
}
}
})
t.Run("Return all values without ones out of capacity", func(t *testing.T) {
// setup
status := ggping.NewStatus(3)
status.Update(1)
status.Update(2)
status.Update(3)
status.Update(4)
expect := []float64{2, 3, 4}
// test & verify
for i, v := range status.GetAll() {
if v != expect[i] {
t.Errorf("expect: %g, actual: %g", expect[i], v)
}
}
})
}
func TestStatus_GetMax(t *testing.T) {
t.Run("Return max value (all fit in capacity)", func(t *testing.T) {
// setup
status := ggping.NewStatus(3)
status.Update(1)
status.Update(2)
var expect float64 = 2
// test & verify
if status.GetMax() != expect {
t.Errorf("expect: %g, actual: %g", expect, status.GetMax())
}
})
t.Run("Return max value ignoring ones out of capacity", func(t *testing.T) {
// setup
status := ggping.NewStatus(3)
status.Update(5)
status.Update(4)
status.Update(3)
status.Update(2)
status.Update(1)
var expect float64 = 3
// test & verify
if status.GetMax() != expect {
t.Errorf("expect: %g, actual: %g", expect, status.GetMax())
}
})
}