| 50 | } |
| 51 | |
| 52 | func TestStatVar_OddCount(t *testing.T) { |
| 53 | var s StatVar |
| 54 | // [1, 3, 5] — odd number of values |
| 55 | for _, v := range []float64{5, 1, 3} { |
| 56 | s.Add(v) |
| 57 | } |
| 58 | |
| 59 | assert.Equal(t, 3, s.Count(), "odd: count should be 3") |
| 60 | assert.InDelta(t, 1.0, s.Min(), 1e-9, "odd: min should be 1") |
| 61 | assert.InDelta(t, 5.0, s.Max(), 1e-9, "odd: max should be 5") |
| 62 | assert.InDelta(t, 3.0, s.Mean(), 1e-9, "odd: mean should be 3") |
| 63 | assert.InDelta(t, 3.0, s.Median(), 1e-9, "odd: median of [1,3,5] should be 3") |
| 64 | } |
| 65 | |
| 66 | func TestStatVar_EvenCount(t *testing.T) { |
| 67 | var s StatVar |