MCPcopy Create free account
hub / github.com/apache/thrift / TestWriteJSONProtocolByte

Function TestWriteJSONProtocolByte

lib/go/thrift/json_protocol_test.go:90–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestWriteJSONProtocolByte(t *testing.T) {
91 thetype := "byte"
92 trans := NewTMemoryBuffer()
93 p := NewTJSONProtocol(trans)
94 for _, value := range BYTE_VALUES {
95 if e := p.WriteByte(context.Background(), value); e != nil {
96 t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error())
97 }
98 if e := p.Flush(context.Background()); e != nil {
99 t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error())
100 }
101 s := trans.String()
102 if s != fmt.Sprint(value) {
103 t.Fatalf("Bad value for %s %v: %s", thetype, value, s)
104 }
105 v := int8(0)
106 if err := json.Unmarshal([]byte(s), &v); err != nil || v != value {
107 t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v)
108 }
109 trans.Reset()
110 }
111 trans.Close()
112}
113
114func TestReadJSONProtocolByte(t *testing.T) {
115 thetype := "byte"

Callers

nothing calls this directly

Calls 8

WriteByteMethod · 0.95
FlushMethod · 0.95
CloseMethod · 0.95
NewTMemoryBufferFunction · 0.85
NewTJSONProtocolFunction · 0.85
StringMethod · 0.65
ResetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected