(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func (s) TestFractionMatcherMatch(t *testing.T) { |
| 121 | const fraction = 500000 |
| 122 | fm := newFractionMatcher(fraction) |
| 123 | defer func() { |
| 124 | RandInt64n = rand.Int64N |
| 125 | }() |
| 126 | |
| 127 | // rand > fraction, should return false. |
| 128 | RandInt64n = func(int64) int64 { |
| 129 | return fraction + 1 |
| 130 | } |
| 131 | if matched := fm.match(); matched { |
| 132 | t.Errorf("match() = %v, want not match", matched) |
| 133 | } |
| 134 | |
| 135 | // rand == fraction, should return true. |
| 136 | RandInt64n = func(int64) int64 { |
| 137 | return fraction |
| 138 | } |
| 139 | if matched := fm.match(); !matched { |
| 140 | t.Errorf("match() = %v, want match", matched) |
| 141 | } |
| 142 | |
| 143 | // rand < fraction, should return true. |
| 144 | RandInt64n = func(int64) int64 { |
| 145 | return fraction - 1 |
| 146 | } |
| 147 | if matched := fm.match(); !matched { |
| 148 | t.Errorf("match() = %v, want match", matched) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | func (s) TestMatchTypeForDomain(t *testing.T) { |
| 153 | tests := []struct { |
nothing calls this directly
no test coverage detected