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

Function TestReadJSONProtocolByte

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

Source from the content-addressed store, hash-verified

112}
113
114func TestReadJSONProtocolByte(t *testing.T) {
115 thetype := "byte"
116 for _, value := range BYTE_VALUES {
117 trans := NewTMemoryBuffer()
118 p := NewTJSONProtocol(trans)
119 trans.WriteString(strconv.Itoa(int(value)))
120 trans.Flush(context.Background())
121 s := trans.String()
122 v, e := p.ReadByte(context.Background())
123 if e != nil {
124 t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error())
125 }
126 if v != value {
127 t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v)
128 }
129 if err := json.Unmarshal([]byte(s), &v); err != nil || v != value {
130 t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v)
131 }
132 trans.Reset()
133 trans.Close()
134 }
135}
136
137func TestWriteJSONProtocolI16(t *testing.T) {
138 thetype := "int16"

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected