(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func TestIntervalOf(t *testing.T) { |
| 201 | tc := []struct { |
| 202 | ts, start, end, step uint64 |
| 203 | instant bool |
| 204 | expected int |
| 205 | }{ |
| 206 | // start <= step |
| 207 | { |
| 208 | start: 1, |
| 209 | step: 1, |
| 210 | expected: -1, |
| 211 | }, |
| 212 | { |
| 213 | start: 9, |
| 214 | step: 10, |
| 215 | expected: -1, |
| 216 | }, |
| 217 | { |
| 218 | ts: 0, |
| 219 | end: 1, |
| 220 | step: 1, |
| 221 | instant: false, |
| 222 | expected: -1, |
| 223 | }, |
| 224 | { |
| 225 | ts: 0, |
| 226 | start: 0, |
| 227 | end: 1, |
| 228 | step: 1, |
| 229 | instant: true, |
| 230 | expected: 0, // start and end are inclusive for instant queries |
| 231 | }, |
| 232 | { |
| 233 | ts: 10, |
| 234 | start: 0, |
| 235 | end: 10, |
| 236 | step: 100, |
| 237 | instant: true, |
| 238 | expected: 0, // start and end are inclusive for instant queries |
| 239 | }, |
| 240 | { |
| 241 | ts: 98, |
| 242 | start: 0, |
| 243 | end: 10, |
| 244 | step: 99, |
| 245 | instant: true, |
| 246 | expected: -1, // outside of range, range is not aligned |
| 247 | }, |
| 248 | { |
| 249 | ts: 10, |
| 250 | start: 1, |
| 251 | end: 10, |
| 252 | step: 1, |
| 253 | instant: false, |
| 254 | expected: 8, // 9th interval: (9;10] |
| 255 | }, |
| 256 | { |
| 257 | ts: 1, |
nothing calls this directly
no test coverage detected