From 7e93fcd2165e374013b2591cdf596d1ec6a88da9 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Wed, 1 Jan 2014 16:10:19 -0800 Subject: [PATCH] Added some test coverage for the String method --- ostat_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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") + } +}