(t *testing.T)
| 218 | } |
| 219 | |
| 220 | func TestReadWriterDuration(t *testing.T) { |
| 221 | var buf bytes.Buffer |
| 222 | wr := NewWriter(&buf) |
| 223 | |
| 224 | for range 10000 { |
| 225 | buf.Reset() |
| 226 | dur := time.Duration(rand.Int63()) |
| 227 | err := wr.WriteDuration(dur) |
| 228 | if err != nil { |
| 229 | t.Errorf("Error with %v: %s", dur, err) |
| 230 | } |
| 231 | err = wr.Flush() |
| 232 | if err != nil { |
| 233 | t.Fatal(err) |
| 234 | } |
| 235 | |
| 236 | bts := buf.Bytes() |
| 237 | |
| 238 | if bts[0] != mint64 { |
| 239 | t.Errorf("Leading byte was %x and not %x", bts[0], mint64) |
| 240 | } |
| 241 | |
| 242 | wr := NewReader(&buf) |
| 243 | d, err := wr.ReadDuration() |
| 244 | if err != nil { |
| 245 | t.Errorf("Error reading duration: %v", err) |
| 246 | } |
| 247 | if d != dur { |
| 248 | t.Errorf("Got duration %v, want %v", d, dur) |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | func BenchmarkWriteFloat64(b *testing.B) { |
| 254 | f := rand.Float64() |
nothing calls this directly
no test coverage detected
searching dependent graphs…