MCPcopy
hub / github.com/golang/protobuf / TestBytesPrimitives

Function TestBytesPrimitives

proto/proto_test.go:323–336  ·  view source on GitHub ↗

Simple tests for bytes

(t *testing.T)

Source from the content-addressed store, hash-verified

321
322// Simple tests for bytes
323func TestBytesPrimitives(t *testing.T) {
324 bb := new(proto.Buffer)
325 want := []byte("now is the time")
326 if err := bb.EncodeRawBytes(want); err != nil {
327 t.Errorf("EncodeRawBytes error: %v", err)
328 }
329 got, err := bb.DecodeRawBytes(false)
330 if err != nil {
331 t.Errorf("DecodeRawBytes error: %v", err)
332 }
333 if !bytes.Equal(got, want) {
334 t.Errorf("got %q\nwant %q", got, want)
335 }
336}
337
338// Simple tests for strings
339func TestStringPrimitives(t *testing.T) {

Callers

nothing calls this directly

Calls 2

EncodeRawBytesMethod · 0.80
DecodeRawBytesMethod · 0.80

Tested by

no test coverage detected