MCPcopy Create free account
hub / github.com/aws/smithy-go / testEncode

Function testEncode

document/json/encoder_test.go:134–152  ·  view source on GitHub ↗
(t *testing.T, tt testCase)

Source from the content-addressed store, hash-verified

132}
133
134func testEncode(t *testing.T, tt testCase) {
135 t.Helper()
136
137 e := json.NewEncoder(func(options *json.EncoderOptions) {
138 *options = tt.encoderOptions
139 })
140
141 encodeBytes, err := e.Encode(tt.actual)
142 if (err != nil) != tt.wantErr {
143 t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr)
144 }
145
146 expect := MustJSONUnmarshal(tt.json, !tt.disableJSONNumber)
147 got := MustJSONUnmarshal(encodeBytes, !tt.disableJSONNumber)
148
149 if !reflect.DeepEqual(expect, got) {
150 t.Errorf("%v != %v", expect, got)
151 }
152}

Callers 1

TestEncoder_EncodeFunction · 0.85

Calls 5

EncodeMethod · 0.95
NewEncoderFunction · 0.92
MustJSONUnmarshalFunction · 0.85
HelperMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected