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

Function TestReadSimpleJSONProtocolByte

lib/go/thrift/simple_json_protocol_test.go:108–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected