-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsma_test.go
47 lines (36 loc) · 812 Bytes
/
sma_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
package ma_test
import (
"testing"
"github.com/MicahParks/go-ma"
)
const (
testPeriod = 10
)
func BenchmarkSMABig_Calculate(b *testing.B) {
sma, _ := ma.NewBigSMA(bigPrices[:testPeriod])
for _, p := range bigPrices[testPeriod:] {
sma.Calculate(p)
}
}
func BenchmarkSMAFloat_Calculate(b *testing.B) {
sma, _ := ma.NewSMA(prices[:testPeriod])
for i, p := range prices[testPeriod:] {
if smaResults[i] != sma.Calculate(p) {
b.FailNow()
}
}
}
func TestSMABig_Calculate(t *testing.T) {
sma, _ := ma.NewBigSMA(bigPrices[:testPeriod])
for _, p := range bigPrices[testPeriod:] {
sma.Calculate(p)
}
}
func TestSMA_Calculate(t *testing.T) {
sma, _ := ma.NewSMA(prices[:testPeriod])
for i, p := range prices[testPeriod:] {
if smaResults[i] != sma.Calculate(p) {
t.FailNow()
}
}
}