Added some test coverage for the String method

This commit is contained in:
Stephen McQuay 2014-01-01 16:10:19 -08:00
parent 3287aa13a1
commit 7e93fcd216

View File

@ -1,6 +1,7 @@
package ostat
import (
"fmt"
"math"
"testing"
)
@ -267,3 +268,14 @@ func TestMidStreamStatWithData(t *testing.T) {
t.Errorf("max: %f != %f != %f", mss.Max, mss.Max, max2)
}
}
func TestString(t *testing.T) {
ps := NewPopulationStat()
for _, v := range []float64{1, 1, 2, 2} {
ps.Push(v)
}
expected := "{n:4 min:1 max:2 mean:1.5 variance:0.25 stdDev:0.5}"
if fmt.Sprint(ps) != expected {
t.Errorf("failed to generate correct string")
}
}