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

Function TestReadJSONProtocolString

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

Source from the content-addressed store, hash-verified

376}
377
378func TestReadJSONProtocolString(t *testing.T) {
379 thetype := "string"
380 for _, value := range STRING_VALUES {
381 trans := NewTMemoryBuffer()
382 p := NewTJSONProtocol(trans)
383 trans.WriteString(jsonQuote(value))
384 trans.Flush(context.Background())
385 s := trans.String()
386 v, e := p.ReadString(context.Background())
387 if e != nil {
388 t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error())
389 }
390 if v != value {
391 t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v)
392 }
393 v1 := new(string)
394 if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value {
395 t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1)
396 }
397 trans.Reset()
398 trans.Close()
399 }
400}
401
402func TestWriteJSONProtocolBinary(t *testing.T) {
403 thetype := "binary"

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected