Browse Source

added coverage

tags/v1.1.0
Stephen McQuay 3 years ago
parent
commit
78387b0284
No known key found for this signature in database GPG Key ID: 1ABF428F71BAFC3D
1 changed files with 27 additions and 1 deletions
  1. +27
    -1
      ostat_test.go

+ 27
- 1
ostat_test.go 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)
}
}

Loading…
Cancel
Save