MCPcopy
hub / github.com/tinylib/msgp / TestWriteTime

Function TestWriteTime

msgp/write_test.go:407–430  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

405func BenchmarkWrite2048Bytes(b *testing.B) { benchwrBytes(2048, b) }
406
407func TestWriteTime(t *testing.T) {
408 var buf bytes.Buffer
409 wr := NewWriter(&buf)
410 tm := time.Now()
411 err := wr.WriteTime(tm)
412 if err != nil {
413 t.Fatal(err)
414 }
415 err = wr.Flush()
416 if err != nil {
417 t.Fatal(err)
418 }
419 if buf.Len() != 15 {
420 t.Errorf("expected time.Time to be %d bytes; got %d", 15, buf.Len())
421 }
422
423 newt, err := NewReader(&buf).ReadTime()
424 if err != nil {
425 t.Fatal(err)
426 }
427 if !newt.Equal(tm) {
428 t.Errorf("in/out not equal; %s in and %s out", tm, newt)
429 }
430}
431
432func BenchmarkWriteTime(b *testing.B) {
433 t := time.Now()

Callers

nothing calls this directly

Calls 7

WriteTimeMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
NewReaderFunction · 0.85
ReadTimeMethod · 0.80
LenMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…