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

Function TestMarshalTextFailing

proto/text_test.go:588–604  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

586}
587
588func TestMarshalTextFailing(t *testing.T) {
589 // Try lots of different sizes to exercise more error code-paths.
590 for lim := 0; lim < len(text); lim++ {
591 buf := new(limitedWriter)
592 buf.limit = lim
593 err := proto.MarshalText(buf, newTestMessage())
594 // We expect a certain error, but also some partial results in the buffer.
595 if err != outOfSpace {
596 t.Errorf("error mismatch: got %v, want %v", err, outOfSpace)
597 }
598 got := buf.b.String()
599 want := text[:buf.limit]
600 if got != want {
601 t.Errorf("text mismatch:\n\ngot:\n%v\n\nwant:\n%v", got, want)
602 }
603 }
604}
605
606func TestFloats(t *testing.T) {
607 tests := []struct {

Callers

nothing calls this directly

Calls 3

MarshalTextFunction · 0.92
newTestMessageFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected