TestSwap tests that swap() on the callCounter successfully has the desired end result of inactive bucket containing the previous active buckets data, and the active bucket being cleared.
(t *testing.T)
| 72 | // end result of inactive bucket containing the previous active buckets data, |
| 73 | // and the active bucket being cleared. |
| 74 | func (s) TestSwap(t *testing.T) { |
| 75 | cc := newCallCounter() |
| 76 | ab := cc.activeBucket.Load() |
| 77 | ab.numSuccesses = 1 |
| 78 | ab.numFailures = 2 |
| 79 | cc.inactiveBucket.numSuccesses = 4 |
| 80 | cc.inactiveBucket.numFailures = 5 |
| 81 | ib := cc.inactiveBucket |
| 82 | cc.swap() |
| 83 | // Inactive should pick up active's data, active should be swapped to zeroed |
| 84 | // inactive. |
| 85 | ccWant := newCallCounter() |
| 86 | ccWant.inactiveBucket.numSuccesses = 1 |
| 87 | ccWant.inactiveBucket.numFailures = 2 |
| 88 | ccWant.activeBucket.Store(ib) |
| 89 | if diff := cmp.Diff(cc, ccWant); diff != "" { |
| 90 | t.Fatalf("callCounter is different than expected, diff (-got +want): %v", diff) |
| 91 | } |
| 92 | } |
nothing calls this directly
no test coverage detected