diff --git a/ostat_test.go b/ostat_test.go index ef1ce1f..e9ace90 100644 --- a/ostat_test.go +++ b/ostat_test.go @@ -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") + } +}