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

Function TestAppendAndWriteCompatibility

msgp/extension_test.go:132–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func TestAppendAndWriteCompatibility(t *testing.T) {
133 var bts []byte
134 var buf bytes.Buffer
135 en := NewWriter(&buf)
136
137 for range 24 {
138 buf.Reset()
139 e := randomExt()
140 bts, _ = AppendExtension(bts[0:0], &e)
141 en.WriteExtension(&e)
142 en.Flush()
143
144 if !bytes.Equal(buf.Bytes(), bts) {
145 t.Errorf("the outputs are different:\n\t%x\n\t%x", buf.Bytes(), bts)
146 }
147
148 _, err := ReadExtensionBytes(bts, &e)
149 if err != nil {
150 t.Errorf("error with extension (length %d): %s", len(bts), err)
151 }
152 }
153}
154
155func BenchmarkExtensionReadWrite(b *testing.B) {
156 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 8

WriteExtensionMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
randomExtFunction · 0.85
AppendExtensionFunction · 0.85
ReadExtensionBytesFunction · 0.85
ResetMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…