MCPcopy
hub / github.com/rs/zerolog / TestAppendDurationFloat

Function TestAppendDurationFloat

internal/json/time_test.go:278–302  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestAppendDurationFloat(t *testing.T) {
279 for _, tt := range internal.DurTestcases {
280 dur := tt.Duration
281 want := []byte{}
282 want = append(want, []byte(fmt.Sprintf("%v", dur.Microseconds()))...)
283 got := enc.AppendDuration([]byte{}, dur, time.Microsecond, "", false, -1)
284 if !bytes.Equal(got, want) {
285 t.Errorf("AppendDuration(%v)=\ngot: %s\nwant: %s",
286 dur,
287 string(got),
288 string(want))
289 }
290
291 want = []byte{}
292 fraction := float64(dur) / float64(time.Millisecond)
293 want = append(want, []byte(fmt.Sprintf("%v", fraction))...)
294 got = enc.AppendDuration([]byte{}, dur, time.Millisecond, "", false, -1)
295 if !bytes.Equal(got, want) {
296 t.Errorf("AppendDuration(%v)=\ngot: %s\nwant: %s",
297 dur,
298 string(got),
299 string(want))
300 }
301 }
302}
303func TestAppendDurationInteger(t *testing.T) {
304 for _, tt := range internal.DurTestcases {
305 dur := tt.Duration

Callers

nothing calls this directly

Calls 1

AppendDurationMethod · 0.65

Tested by

no test coverage detected