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

Function TestEncoder_Encode

eventstream/encode_test.go:11–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestEncoder_Encode(t *testing.T) {
12 cases, err := readPositiveTests("testdata")
13 if err != nil {
14 t.Fatalf("failed to load positive tests, %v", err)
15 }
16
17 for _, c := range cases {
18 var w bytes.Buffer
19 encoder := NewEncoder()
20
21 err = encoder.Encode(&w, c.Decoded.Message())
22 if err != nil {
23 t.Fatalf("%s, failed to encode message, %v", c.Name, err)
24 }
25
26 if e, a := c.Encoded, w.Bytes(); !reflect.DeepEqual(e, a) {
27 t.Errorf("%s, expect:\n%v\nactual:\n%v\n", c.Name,
28 hex.Dump(e), hex.Dump(a))
29 }
30 }
31}
32
33func BenchmarkEncode(b *testing.B) {
34 var w bytes.Buffer

Callers

nothing calls this directly

Calls 6

EncodeMethod · 0.95
readPositiveTestsFunction · 0.85
MessageMethod · 0.80
ErrorfMethod · 0.80
NewEncoderFunction · 0.70
BytesMethod · 0.65

Tested by

no test coverage detected