added coverage

This commit is contained in:
Stephen McQuay 2016-07-31 22:41:04 -07:00
parent 3e9c1a9df6
commit 78387b0284
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D

View File

@ -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)
}
}