(t *testing.T)
| 316 | } |
| 317 | } |
| 318 | func TestAppendDurations(t *testing.T) { |
| 319 | array := make([]time.Duration, len(internal.DurTestcases)) |
| 320 | want := make([]byte, 0) |
| 321 | want = append(want, '[') |
| 322 | for i, tt := range internal.DurTestcases { |
| 323 | array[i] = tt.Duration |
| 324 | whole := int(tt.Duration) / int(time.Microsecond) |
| 325 | want = append(want, []byte(fmt.Sprintf("%v", whole))...) |
| 326 | if i < len(internal.DurTestcases)-1 { |
| 327 | want = append(want, ',') |
| 328 | } |
| 329 | } |
| 330 | want = append(want, ']') |
| 331 | |
| 332 | got := enc.AppendDurations([]byte{}, array, time.Microsecond, "", false, -1) |
| 333 | if !bytes.Equal(got, want) { |
| 334 | t.Errorf("AppendDurations(%v)\ngot: %s\nwant: %s", |
| 335 | array, |
| 336 | string(got), |
| 337 | string(want)) |
| 338 | } |
| 339 | |
| 340 | // now empty array case |
| 341 | array = make([]time.Duration, 0) |
| 342 | want = make([]byte, 0) |
| 343 | want = append(want, '[') |
| 344 | want = append(want, ']') |
| 345 | got = enc.AppendDurations([]byte{}, array, time.Microsecond, "", false, -1) |
| 346 | if !bytes.Equal(got, want) { |
| 347 | t.Errorf("AppendDurations(%v)\ngot: %s\nwant: %s", |
| 348 | array, |
| 349 | string(got), |
| 350 | string(want)) |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | func BenchmarkAppendTime(b *testing.B) { |
| 355 | tests := map[string]string{ |
nothing calls this directly
no test coverage detected