24 lines
948 B
Go
24 lines
948 B
Go
package gota
|
|
|
|
import "testing"
|
|
|
|
func TestTRIX(t *testing.T) {
|
|
list := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
|
|
|
|
// expList is generated by the following code:
|
|
// expList, _ := talib.Trix(list, 4, nil)
|
|
expList := []float64{18.181818181818187, 15.384615384615374, 13.33333333333333, 11.764705882352944, 10.526315789473696, 8.304761904761904, 5.641927541329594, 3.0392222148232007, 0.7160675740302658, -1.2848911076603242, -2.9999661985600667, -4.493448741755901, -5.836238000516913, -7.099092024379772, -8.352897627933453, -9.673028502435233, -11.147601363985949, -12.891818138458877, -15.074463280730022}
|
|
|
|
trix := NewTRIX(4, WarmSMA)
|
|
var actList []float64
|
|
for _, v := range list {
|
|
if vOut := trix.Add(v); trix.Warmed() {
|
|
actList = append(actList, vOut)
|
|
}
|
|
}
|
|
|
|
if diff := diffFloats(expList, actList, 1E-7); diff != "" {
|
|
t.Errorf("unexpected floats:\n%s", diff)
|
|
}
|
|
}
|