fishy commented on code in PR #3125: URL: https://github.com/apache/thrift/pull/3125#discussion_r2052775198
########## lib/go/thrift/duplicate_protocol_test.go: ########## @@ -0,0 +1,52 @@ +package thrift + +import ( + "bytes" + "context" + "encoding/json" + "testing" +) + +func TestDuplicateToJSONReadMakesEqualJSON(t *testing.T) { + delegateBuf := NewTMemoryBuffer() + iprot := NewTJSONProtocolFactory().GetProtocol(delegateBuf) + + s := NewMyTestStruct() + ctx := context.Background() + s.Write(ctx, iprot) + + iprot.Flush(ctx) + jsonBytesWritten := delegateBuf.Bytes() + + if err := json.Unmarshal(jsonBytesWritten, NewMyTestStruct()); err != nil { + t.Errorf("error unmarshaling written bytes: %s", err) + } + + duplicateBuf := NewTMemoryBuffer() + dupProto := NewTJSONProtocolFactory().GetProtocol(duplicateBuf) + proto := &TDuplicateToProtocol{ + Delegate: NewTJSONProtocolFactory().GetProtocol(delegateBuf), + DuplicateTo: dupProto, + } + + if err := s.Read(ctx, proto); err != nil { + t.Errorf("error reading struct from DuplicateTo: %s", err) + } + dupProto.Flush(ctx) + + jsonBytesRead := duplicateBuf.Bytes() + + if !bytes.Equal(jsonBytesWritten, jsonBytesRead) { + t.Errorf(`bytes read into duplicate do not equal bytes written + read: + %+v + written: + %+v Review Comment: since we are using TJSONProtocol here, output the string will be more useful: ```suggestion %s written: %s ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@thrift.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org