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
|
package stats_test
import (
"testing"
"github.com/montanaflynn/stats"
)
// Create working sample data to test if the legacy
// functions cause a runtime crash or return an error
func TestLegacy(t *testing.T) {
// Slice of data
s := []float64{-10, -10.001, 5, 1.1, 2, 3, 4.20, 5}
// Slice of coordinates
d := []stats.Coordinate{
{1, 2.3},
{2, 3.3},
{3, 3.7},
{4, 4.3},
{5, 5.3},
}
// VarP rename compatibility
_, err := stats.VarP(s)
if err != nil {
t.Errorf("VarP not successfully returning PopulationVariance.")
}
// VarS rename compatibility
_, err = stats.VarS(s)
if err != nil {
t.Errorf("VarS not successfully returning SampleVariance.")
}
// StdDevP rename compatibility
_, err = stats.StdDevP(s)
if err != nil {
t.Errorf("StdDevP not successfully returning StandardDeviationPopulation.")
}
// StdDevS rename compatibility
_, err = stats.StdDevS(s)
if err != nil {
t.Errorf("StdDevS not successfully returning StandardDeviationSample.")
}
// LinReg rename compatibility
_, err = stats.LinReg(d)
if err != nil {
t.Errorf("LinReg not successfully returning LinearRegression.")
}
// ExpReg rename compatibility
_, err = stats.ExpReg(d)
if err != nil {
t.Errorf("ExpReg not successfully returning ExponentialRegression.")
}
// LogReg rename compatibility
_, err = stats.LogReg(d)
if err != nil {
t.Errorf("LogReg not successfully returning LogarithmicRegression.")
}
}
|