-
Notifications
You must be signed in to change notification settings - Fork 6
/
movavg_suite_test.go
53 lines (39 loc) · 929 Bytes
/
movavg_suite_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
package movavg_test
import (
"testing"
. "github.com/mxmCherry/movavg"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestMovavg(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Movavg Suite")
}
// ----------------------------------------------------------------------------
var _ MA = (*mockMA)(nil)
type mockMA struct {
addArgs []float64
addRes float64
avgRes float64
}
func (a *mockMA) Add(v float64) float64 {
a.addArgs = append(a.addArgs, v)
return a.addRes
}
func (a *mockMA) Avg() float64 {
return a.avgRes
}
// ----------------------------------------------------------------------------
var _ MultiMA = (*mockMultiMA)(nil)
type mockMultiMA struct {
addArgs []float64
addRes []float64
avgRes []float64
}
func (s *mockMultiMA) Add(v float64) []float64 {
s.addArgs = append(s.addArgs, v)
return s.addRes
}
func (s *mockMultiMA) Avg() []float64 {
return s.avgRes
}