| func TestDuplicateToJSONReadMakesEqualJSON(t *testing.T) { |
| delegateBuf := NewTMemoryBuffer() |
| iprot := NewTJSONProtocolFactory().GetProtocol(delegateBuf) |
| ctx := context.Background() |
| 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), |
| if err := s.Read(ctx, proto); err != nil { |
| t.Errorf("error reading struct from DuplicateTo: %s", err) |
| jsonBytesRead := duplicateBuf.Bytes() |
| if !bytes.Equal(jsonBytesWritten, jsonBytesRead) { |
| t.Errorf(`bytes read into duplicate do not equal bytes written |
| `, jsonBytesRead, jsonBytesWritten) |
| if err := dup.Read(ctx, dupProto); err != nil { |
| t.Errorf("error reading struct from duplicated protocol: %s", err) |