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

Function TestWriteSimpleJSONProtocolByte

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected