From 78387b0284b18eb39a959086954352dcf97e543c Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Sun, 31 Jul 2016 22:41:04 -0700 Subject: [PATCH] added coverage --- ostat_test.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ostat_test.go b/ostat_test.go index 9d5defc..2c98d3e 100644 --- a/ostat_test.go +++ b/ostat_test.go @@ -282,7 +282,6 @@ func TestString(t *testing.T) { } } - func TestJson(t *testing.T) { ps := NewPopulationStat() for _, v := range []float64{1, 1, 2, 2} { @@ -297,3 +296,30 @@ func TestJson(t *testing.T) { t.Fatalf("wrong json encoding; got %q, want %q", got, want) } } + +func TestN(t *testing.T) { + ps := NewPopulationStat() + for _, v := range []float64{1, 1, 2, 2} { + ps.Push(v) + } + if got, want := ps.N(), uint64(4); got != want { + t.Fatalf("unexpected number of values in ps: got %v, want %v", got, want) + } +} + +func TestCI(t *testing.T) { + ps := NewPopulationStat() + for _, v := range []float64{1, 1, 2, 2} { + ps.Push(v) + } + cil, cir := ps.CI() + wantl, wantr := float64(1.01001), float64(1.98999) + + if got, want := cil, wantl; got != want { + t.Errorf("unexpected lower confidence interval; got %v, want %v", got, want) + } + + if got, want := cir, wantr; got != want { + t.Errorf("unexpected upper confidence interval; got %v, want %v", got, want) + } +}