(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestNewStat(t *testing.T) { |
| 18 | var a = assert.NewAssertion(t) |
| 19 | |
| 20 | { |
| 21 | var stat = cachehits.NewStat(20) |
| 22 | for i := 0; i < 1000; i++ { |
| 23 | stat.IncreaseCached("a") |
| 24 | } |
| 25 | |
| 26 | a.IsTrue(stat.IsGood("a")) |
| 27 | } |
| 28 | |
| 29 | { |
| 30 | var stat = cachehits.NewStat(5) |
| 31 | for i := 0; i < 10000; i++ { |
| 32 | stat.IncreaseCached("a") |
| 33 | } |
| 34 | for i := 0; i < 500; i++ { |
| 35 | stat.IncreaseHit("a") |
| 36 | } |
| 37 | |
| 38 | stat.IncreaseHit("b") // empty |
| 39 | |
| 40 | a.IsTrue(stat.IsGood("a")) |
| 41 | a.IsTrue(stat.IsGood("b")) |
| 42 | } |
| 43 | |
| 44 | { |
| 45 | var stat = cachehits.NewStat(10) |
| 46 | for i := 0; i < 10000; i++ { |
| 47 | stat.IncreaseCached("a") |
| 48 | } |
| 49 | for i := 0; i < 1000; i++ { |
| 50 | stat.IncreaseHit("a") |
| 51 | } |
| 52 | |
| 53 | stat.IncreaseHit("b") // empty |
| 54 | |
| 55 | a.IsTrue(stat.IsGood("a")) |
| 56 | a.IsTrue(stat.IsGood("b")) |
| 57 | } |
| 58 | |
| 59 | { |
| 60 | var stat = cachehits.NewStat(5) |
| 61 | for i := 0; i < 100001; i++ { |
| 62 | stat.IncreaseCached("a") |
| 63 | } |
| 64 | for i := 0; i < 4999; i++ { |
| 65 | stat.IncreaseHit("a") |
| 66 | } |
| 67 | |
| 68 | a.IsFalse(stat.IsGood("a")) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestNewStat_Memory(t *testing.T) { |
| 73 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected