|
12345678910111213141516171819202122232425 |
- package speedstats
-
- import (
- "testing"
- "time"
-
- . "github.com/smartystreets/goconvey/convey"
- )
-
- func Test_Stats(t *testing.T) {
- Convey("Stats", t, func() {
- stats := Stats{}
- stats.Record(100, time.Second)
- So(stats.AvarageSpeed, ShouldAlmostEqual, 100, 0.01)
-
- stats.Step()
- So(stats.AvarageSpeed, ShouldAlmostEqual, 80, 0.01)
-
- stats.Record(200, time.Second)
- So(stats.AvarageSpeed, ShouldAlmostEqual, 120, 0.01)
-
- stats.Step()
- So(stats.AvarageSpeed, ShouldAlmostEqual, 96, 0.01)
- })
- }
|